mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 23:33: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
|
||||||
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
|
if not resource then
|
||||||
resource = modname
|
resource = modname
|
||||||
modname = minetest.get_current_modname()
|
modname = minetest.get_current_modname()
|
||||||
end
|
end
|
||||||
return minetest.get_modpath(modname) .. "/" .. resource
|
return table.concat({minetest.get_modpath(modname), resource, ...}, modlib.dir_delim)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function loadfile_exports(filename)
|
local function loadfile_exports(filename)
|
||||||
@ -50,15 +62,6 @@ local function loadfile_exports(filename)
|
|||||||
return env
|
return env
|
||||||
end
|
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{
|
for _, component in ipairs{
|
||||||
"mod",
|
"mod",
|
||||||
"conf",
|
"conf",
|
||||||
|
Loading…
Reference in New Issue
Block a user