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
|
||||
|
||||
-- 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
|
||||
for _, alias in pairs(aliases) do
|
||||
modlib[alias] = comp
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
modlib.conf.build_setting_tree()
|
||||
|
||||
modlib.mod.get_resource = get_resource
|
||||
modlib.mod.loadfile_exports = loadfile_exports
|
||||
|
||||
_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
|
||||
function include(modname, file)
|
||||
if not file then
|
||||
|
Loading…
Reference in New Issue
Block a user