diff --git a/init.lua b/init.lua index 708860c..b66e13e 100644 --- a/init.lua +++ b/init.lua @@ -36,7 +36,6 @@ if _VERSION then end end --- TODO get rid of code duplication local function get_resource(modname, resource) if not resource then resource = modname @@ -62,30 +61,27 @@ local components = { func = {}, log = {}, minetest = {}, - math = {number = "local"}, + math = {"number"}, player = {}, table = {}, - text = {string = "local"}, + text = {"string"}, vector = {}, trie = {} } modlib = {} -for component, additional in pairs(components) do +for component, aliases in pairs(components) do local comp = loadfile_exports(get_resource(component .. ".lua")) modlib[component] = comp - for alias, scope in pairs(additional) do - if scope == "global" then - _G[alias] = comp - else - modlib[alias] = comp - end + for _, alias in pairs(aliases) do + modlib[alias] = comp end end modlib.conf.build_setting_tree() +modlib.mod.get_resource = get_resource modlib.mod.loadfile_exports = loadfile_exports _ml = modlib diff --git a/mod.lua b/mod.lua index fb54027..59c85d7 100644 --- a/mod.lua +++ b/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 function include(modname, file) if not file then