get started on group support

This commit is contained in:
wsor4035 2024-06-23 22:01:50 -04:00
parent cc2da8a2a6
commit 81802d90ed
3 changed files with 31 additions and 0 deletions

View File

@ -4,6 +4,9 @@ globals = {
}
read_globals = {
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
"default",
"mcl_sounds",
"ks_sounds",

View File

@ -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

26
src/groups.lua Normal file
View File

@ -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},
})