modules are now correctly loaded in all situations
This commit is contained in:
parent
17d77d4d3c
commit
b59266f42e
@ -47,17 +47,32 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
local full = dir .. "/" .. base .. ".lua"
|
local full = dir .. "/" .. base .. ".lua"
|
||||||
local p = os.locate("modules/" .. full) or
|
|
||||||
os.locate(full) or
|
|
||||||
os.locate(name .. ".lua")
|
|
||||||
|
|
||||||
if not p then
|
-- list of paths where to look for the module
|
||||||
-- try to load from the embedded script
|
local paths = {
|
||||||
p = "$/" .. full
|
"modules/" .. full,
|
||||||
|
full,
|
||||||
|
name .. ".lua"
|
||||||
|
}
|
||||||
|
|
||||||
|
-- try to locate the module
|
||||||
|
for _, p in ipairs(paths) do
|
||||||
|
local file = os.locate(p)
|
||||||
|
if file then
|
||||||
|
local chunk, err = loadfile(file)
|
||||||
|
if chunk then
|
||||||
|
return chunk
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local chunk, err = loadfile(p)
|
-- didn't find the module in supported paths, try the embedded scripts
|
||||||
return chunk
|
for _, p in ipairs(paths) do
|
||||||
|
local chunk, err = loadfile("$/" .. p)
|
||||||
|
if chunk then
|
||||||
|
return chunk
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user