diff --git a/.luacheckrc b/.luacheckrc index be1d024..916c783 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -4,6 +4,9 @@ globals = { } read_globals = { + string = {fields = {"split"}}, + table = {fields = {"copy", "getn"}}, + "default", "mcl_sounds", "ks_sounds", diff --git a/init.lua b/init.lua index 2013a94..e20cbb9 100644 --- a/init.lua +++ b/init.lua @@ -12,6 +12,8 @@ xcompat.materials = dofile(modpath .. "/src/materials.lua") xcompat.textures = dofile(modpath .. "/src/textures.lua") xcompat.functions = dofile(modpath .. "/src/functions.lua") +dofile(modpath .. "/src/groups.lua") + local function validate_sound(key) if key and xcompat.sounds[key] then return true diff --git a/src/groups.lua b/src/groups.lua new file mode 100644 index 0000000..1799336 --- /dev/null +++ b/src/groups.lua @@ -0,0 +1,26 @@ +local function on_mods_loaded() + for name, def in pairs(minetest.registered_nodes) do + if def.groups and def.groups.xcompat_autohandle_groups and def.groups.xcompat_autohandle_groups==1 then + local groups = table.copy(def.groups) + + groups.xcompat_autohandle_groups = nil + groups.xcompat_was_handled = 1 + + minetest.override_item(name, { + groups = groups + }) + end + end + + --todo: override minetest.register_node to handle groups registered after this point +end + +--sticking it at the front so that our overrides are applied first +table.insert(minetest.registered_on_mods_loaded, 1, on_mods_loaded) + +--test node, delete before merge +minetest.register_node("xcompat:groups_test", { + description = "xCompat Groups test", + groups = {xcompat_autohandle_groups=1}, + tiles = {xcompat.textures.gravel}, +}) \ No newline at end of file