fixes init file, remove old code, add template for core_inventory
This commit is contained in:
1 parent
646b669881
commit
99f7f4eb11
5 files changed
+37
-42
No files matched your search
@@ -1,6 +1,15 @@
|
|||||||
Bridge = {}
|
Bridge = {}
|
||||||
|
|
||||||
local function registerModule(moduleName, moduleTable)
|
function Bridge.RegisterModule(moduleName, moduleTable)
|
||||||
|
if not moduleTable then
|
||||||
|
print("No moduleTable provided for module and no defaultsTable found: ", moduleName)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if Bridge[moduleName] then
|
||||||
|
print("Module already registered:", moduleName)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local wrappedModule = {}
|
local wrappedModule = {}
|
||||||
for functionName, func in pairs(moduleTable) do
|
for functionName, func in pairs(moduleTable) do
|
||||||
wrappedModule[functionName] = func
|
wrappedModule[functionName] = func
|
||||||
@@ -9,38 +18,10 @@ local function registerModule(moduleName, moduleTable)
|
|||||||
Bridge[moduleName] = wrappedModule
|
Bridge[moduleName] = wrappedModule
|
||||||
end
|
end
|
||||||
|
|
||||||
function Bridge.RegisterModule(moduleName, moduleTable, defaultsTable)
|
|
||||||
if not moduleTable then
|
|
||||||
if not defaultsTable then
|
|
||||||
print("No moduleTable or defaultsTable provided for module:", moduleName)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
moduleTable = defaultsTable
|
|
||||||
registerModule(moduleName, moduleTable)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if Bridge[moduleName] then
|
|
||||||
print("Module already registered:", moduleName)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if defaultsTable and type(defaultsTable) == "table" then
|
|
||||||
for functionName, func in pairs(defaultsTable) do
|
|
||||||
if not moduleTable[functionName] then
|
|
||||||
moduleTable[functionName] = func
|
|
||||||
print(string.format("Added function '%s' from defaultsTable to module '%s'", functionName, moduleName))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
registerModule(moduleName, moduleTable)
|
|
||||||
end
|
|
||||||
|
|
||||||
--TODO: Create a way to overide functions or create a new functions for module
|
--TODO: Create a way to overide functions or create a new functions for module
|
||||||
|
|
||||||
Bridge.RegisterModule("Framework", Framework)
|
Bridge.RegisterModule("Framework", Framework)
|
||||||
Bridge.RegisterModule("Inventory", Inventory, DefaultInventory)
|
Bridge.RegisterModule("Inventory", Inventory)
|
||||||
Bridge.RegisterModule("Notify", Notify)
|
Bridge.RegisterModule("Notify", Notify)
|
||||||
Bridge.RegisterModule("Utility", Utility)
|
Bridge.RegisterModule("Utility", Utility)
|
||||||
Bridge.RegisterModule("Progressbar", Progressbar)
|
Bridge.RegisterModule("Progressbar", Progressbar)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
DefaultInventory = DefaultInventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
DefaultInventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
print('client funct')
|
print('client funct')
|
||||||
return Framework.GetItemInfo(item)
|
return Framework.GetItemInfo(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
DefaultInventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
return "https://avatars.githubusercontent.com/u/47620135"
|
return "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
DefaultInventory = DefaultInventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
DefaultInventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
return Framework.AddItem(src, item, count, slot, metadata)
|
return Framework.AddItem(src, item, count, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
DefaultInventory.RemoveItem = function(src, item, count, slot, metadata)
|
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||||
return Framework.RemoveItem(src, item, count, slot, metadata)
|
return Framework.RemoveItem(src, item, count, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
DefaultInventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
return false, print("This Inventory Has Not Been Bridged For An Item Info Feature.")
|
return false, print("This Inventory Has Not Been Bridged For An Item Info Feature.")
|
||||||
end
|
end
|
||||||
|
|
||||||
DefaultInventory.GetItemCount = function(src, item, metadata)
|
Inventory.GetItemCount = function(src, item, metadata)
|
||||||
return Framework.GetItemCount(src, item, metadata)
|
return Framework.GetItemCount(src, item, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
DefaultInventory.GetInventoryItems = function(src)
|
Inventory.GetInventoryItems = function(src)
|
||||||
return Framework.GetPlayerInventory(src)
|
return Framework.GetPlayerInventory(src)
|
||||||
end
|
end
|
||||||
|
|
||||||
DefaultInventory.SetMetadata = function(src, item, slot, metadata)
|
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||||
return Framework.SetMetadata(src, item, slot, metadata)
|
return Framework.SetMetadata(src, item, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
DefaultInventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
||||||
return false, print("This Inventory Has Not Been Bridged For A Stash Feature.")
|
return false, print("This Inventory Has Not Been Bridged For A Stash Feature.")
|
||||||
end
|
end
|
||||||
|
|
||||||
DefaultInventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
return "https://avatars.githubusercontent.com/u/47620135"
|
return "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
if GetResourceState('core_inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
|
Inventory.TestFunction = function(item)
|
||||||
|
return 'test funct client inv'
|
||||||
|
end
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
if GetResourceState('core_inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
|
Inventory.TestFunction = function(item)
|
||||||
|
return 'test funct server inv'
|
||||||
|
end
|
||||||
Reference in new issue
Block a user