mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-25 16:53:46 +01:00
Init cleanup
This commit is contained in:
parent
847bca6f69
commit
27b2de0367
14
init.lua
14
init.lua
@ -36,7 +36,6 @@ if _VERSION then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO get rid of code duplication
|
|
||||||
local function get_resource(modname, resource)
|
local function get_resource(modname, resource)
|
||||||
if not resource then
|
if not resource then
|
||||||
resource = modname
|
resource = modname
|
||||||
@ -62,30 +61,27 @@ local components = {
|
|||||||
func = {},
|
func = {},
|
||||||
log = {},
|
log = {},
|
||||||
minetest = {},
|
minetest = {},
|
||||||
math = {number = "local"},
|
math = {"number"},
|
||||||
player = {},
|
player = {},
|
||||||
table = {},
|
table = {},
|
||||||
text = {string = "local"},
|
text = {"string"},
|
||||||
vector = {},
|
vector = {},
|
||||||
trie = {}
|
trie = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
modlib = {}
|
modlib = {}
|
||||||
|
|
||||||
for component, additional in pairs(components) do
|
for component, aliases in pairs(components) do
|
||||||
local comp = loadfile_exports(get_resource(component .. ".lua"))
|
local comp = loadfile_exports(get_resource(component .. ".lua"))
|
||||||
modlib[component] = comp
|
modlib[component] = comp
|
||||||
for alias, scope in pairs(additional) do
|
for _, alias in pairs(aliases) do
|
||||||
if scope == "global" then
|
|
||||||
_G[alias] = comp
|
|
||||||
else
|
|
||||||
modlib[alias] = comp
|
modlib[alias] = comp
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
modlib.conf.build_setting_tree()
|
modlib.conf.build_setting_tree()
|
||||||
|
|
||||||
|
modlib.mod.get_resource = get_resource
|
||||||
modlib.mod.loadfile_exports = loadfile_exports
|
modlib.mod.loadfile_exports = loadfile_exports
|
||||||
|
|
||||||
_ml = modlib
|
_ml = modlib
|
||||||
|
9
mod.lua
9
mod.lua
@ -1,12 +1,3 @@
|
|||||||
-- get modpath wrapper
|
|
||||||
function get_resource(modname, resource)
|
|
||||||
if not resource then
|
|
||||||
resource = modname
|
|
||||||
modname = minetest.get_current_modname()
|
|
||||||
end
|
|
||||||
return minetest.get_modpath(modname) .. "/" .. resource
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get resource + dofile
|
-- get resource + dofile
|
||||||
function include(modname, file)
|
function include(modname, file)
|
||||||
if not file then
|
if not file then
|
||||||
|
Loading…
Reference in New Issue
Block a user