dfcaverns/df_dependencies/init.lua

41 lines
1.1 KiB
Lua
Raw Normal View History

2022-08-01 19:51:14 +02:00
df_dependencies = {}
local modpath = minetest.get_modpath(minetest.get_current_modname())
2022-08-04 03:22:41 +02:00
df_dependencies.mods_required = {}
2022-08-03 19:38:40 +02:00
df_dependencies.select_required = function(def)
local count = 0
local total = 0
local ret
for mod, item in pairs(def) do
total = total + 1
2022-08-04 03:22:41 +02:00
df_dependencies.mods_required[mod] = true
2022-08-03 19:38:40 +02:00
if minetest.get_modpath(mod) then
count = count + 1
ret = item
end
end
assert(count ~= 0, "Unable to find item for dependency set " .. dump(def))
assert(count == 1, "Found more than one item for dependency set " .. dump(def))
--assert(total == 2, "number of options other than two for " .. dump(def))
return ret
2022-08-01 19:51:14 +02:00
end
2022-08-03 19:38:40 +02:00
df_dependencies.select_optional = function(def)
for mod, item in pairs(def) do
if minetest.get_modpath(mod) then
return item
2022-08-01 19:51:14 +02:00
end
end
end
2022-08-03 19:38:40 +02:00
dofile(modpath.."/nodes.lua")
dofile(modpath.."/sounds.lua")
dofile(modpath.."/helper_functions.lua")
dofile(modpath.."/misc.lua")
2022-08-04 03:22:41 +02:00
minetest.debug(dump(df_dependencies.mods_required))
2022-08-03 19:38:40 +02:00
2022-08-01 19:51:14 +02:00
-- This mod is meant to only exist at initialization time. Other mods should make copies of anything it points to for their own use.
minetest.after(1, function() df_dependencies = nil end)