Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ globals = {
}

read_globals = {
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},

"default",
"mcl_sounds",
"ks_sounds",
Expand Down
2 changes: 2 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions src/groups.lua
Original file line number Diff line number Diff line change
@@ -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},
})