mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 09:13:53 +01:00
Improve mod.get_resource
This commit is contained in:
parent
12826a7840
commit
cfdf3cf67b
25
init.lua
25
init.lua
@ -34,12 +34,24 @@ if _VERSION then
|
||||
end
|
||||
end
|
||||
|
||||
local function get_resource(modname, resource)
|
||||
modlib = {
|
||||
dir_delim = rawget(_G, "DIR_DELIM") or "/",
|
||||
_RG = setmetatable({}, {
|
||||
__index = function(_, index)
|
||||
return rawget(_G, index)
|
||||
end,
|
||||
__newindex = function(_, index, value)
|
||||
return rawset(_G, index, value)
|
||||
end
|
||||
})
|
||||
}
|
||||
|
||||
local function get_resource(modname, resource, ...)
|
||||
if not resource then
|
||||
resource = modname
|
||||
modname = minetest.get_current_modname()
|
||||
end
|
||||
return minetest.get_modpath(modname) .. "/" .. resource
|
||||
return table.concat({minetest.get_modpath(modname), resource, ...}, modlib.dir_delim)
|
||||
end
|
||||
|
||||
local function loadfile_exports(filename)
|
||||
@ -50,15 +62,6 @@ local function loadfile_exports(filename)
|
||||
return env
|
||||
end
|
||||
|
||||
modlib = {_RG = setmetatable({}, {
|
||||
__index = function(_, index)
|
||||
return rawget(_G, index)
|
||||
end,
|
||||
__newindex = function(_, index, value)
|
||||
return rawset(_G, index, value)
|
||||
end
|
||||
})}
|
||||
|
||||
for _, component in ipairs{
|
||||
"mod",
|
||||
"conf",
|
||||
|
Loading…
Reference in New Issue
Block a user