Refactor cLib initialization and modularize server/client libraries
This commit is contained in:
1 parent
7927927394
commit
42fe204615
2 files changed
+109
-24
No files matched your search
@@ -22,7 +22,7 @@ function Bridge.RegisterModule(moduleName, moduleTable)
|
||||
end
|
||||
Bridge[moduleName] = wrappedModule
|
||||
_ENV[moduleName] = wrappedModule -- Add to the ENV table the modules so is more easy and safe to call from inside
|
||||
_ENV.Bridge = Bridge -- Add the bridge too to the _ENV
|
||||
_ENV.Bridge = Bridge -- Add the bridge too to the _ENV
|
||||
|
||||
exports(moduleName, function()
|
||||
return wrappedModule
|
||||
@@ -31,19 +31,26 @@ function Bridge.RegisterModule(moduleName, moduleTable)
|
||||
--trigger update object event
|
||||
TriggerEvent("Bridge:Refresh", moduleName, wrappedModule)
|
||||
end
|
||||
CreateThread(function() -- lets try to load the lib first to use it on the rest of the modules
|
||||
for k, v in pairs(cLib) do
|
||||
if v then
|
||||
Bridge.RegisterModule(k, v)
|
||||
end
|
||||
end
|
||||
end)
|
||||
exports("RegisterModule", Bridge.RegisterModule)
|
||||
|
||||
--TODO: Create a way to overide functions or create a new functions for module
|
||||
|
||||
function Bridge.RegisterModuleFunction(moduleName, functionName, func)
|
||||
assert(moduleName and functionName and func, string.format("Bridge.RegisterModuleFunction(%s, %s, %s) - Invalid arguments", moduleName, functionName, func))
|
||||
assert(moduleName and functionName and func,
|
||||
string.format("Bridge.RegisterModuleFunction(%s, %s, %s) - Invalid arguments", moduleName, functionName, func))
|
||||
Bridge[moduleName] = Bridge[moduleName] or {}
|
||||
Bridge[moduleName][functionName] = func
|
||||
--trigger update object event
|
||||
TriggerEvent("Bridge:Refresh", moduleName, Bridge[moduleName])
|
||||
end
|
||||
|
||||
|
||||
--Bridge
|
||||
Bridge.RegisterModule("Framework", Framework)
|
||||
Bridge.RegisterModule("Inventory", Inventory)
|
||||
@@ -75,23 +82,27 @@ Bridge.RegisterModule("Require", Require)
|
||||
-- Bridge.RegisterModule("Skills", Skills)
|
||||
|
||||
|
||||
for k, v in pairs(cLib) do
|
||||
if v then
|
||||
Bridge.RegisterModule(k, v)
|
||||
|
||||
|
||||
--[[ CreateThread(function() -- using metatables
|
||||
for k, v in pairs(cLib.loaded) do
|
||||
if v then
|
||||
Bridge.RegisterModule(k, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
end) ]]
|
||||
|
||||
exports('Bridge', function()
|
||||
return Bridge
|
||||
end)
|
||||
|
||||
-- ▄▀▀ ██▀ █▀▄ █ █ ██▀ █▀▄
|
||||
-- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄
|
||||
-- ▄▀▀ ██▀ █▀▄ █ █ ██▀ █▀▄
|
||||
-- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄
|
||||
if not IsDuplicityVersion() then goto client end
|
||||
Bridge.RegisterModule('Version', Version)
|
||||
|
||||
-- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀
|
||||
-- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █
|
||||
-- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀
|
||||
-- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █
|
||||
if IsDuplicityVersion() then return end
|
||||
::client::
|
||||
|
||||
|
||||
Reference in new issue
Block a user