version '0.0.7'
This commit is contained in:
1 parent
89a9a371bd
commit
47977ce701
105 files changed
+5036
-1
No files matched your search
@@ -0,0 +1,37 @@
|
||||
|
||||
local loadedModules = {}
|
||||
|
||||
function Require(modulePath, resourceName)
|
||||
if resourceName and type(resourceName) ~= "string" then
|
||||
resourceName = GetCurrentResourceName()
|
||||
end
|
||||
|
||||
if not resourceName then
|
||||
resourceName = "community_bridge"
|
||||
end
|
||||
|
||||
local id = resourceName .. ":" .. modulePath
|
||||
if loadedModules[id] then
|
||||
print("Returning cached module [" .. id .. "]")
|
||||
return loadedModules[id]
|
||||
end
|
||||
|
||||
local file = LoadResourceFile(resourceName, modulePath)
|
||||
if not file then
|
||||
error("Error loading file [" .. id .. "]")
|
||||
end
|
||||
|
||||
local chunk, loadErr = load(file, id)
|
||||
if not chunk then
|
||||
error("Error wrapping module [" .. id .. "] Message: " .. loadErr)
|
||||
end
|
||||
|
||||
local success, result = pcall(chunk)
|
||||
if not success then
|
||||
error("Error executing module [" .. id .. "] Message: " .. result)
|
||||
end
|
||||
loadedModules[id] = result
|
||||
return result
|
||||
end
|
||||
|
||||
exports('Require', Require)
|
||||
Reference in new issue
Block a user