mirror of
https://github.com/mt-mods/xcompat.git
synced 2025-01-03 14:50:40 +01:00
get started on group support
This commit is contained in:
parent
cc2da8a2a6
commit
81802d90ed
@ -4,6 +4,9 @@ globals = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
read_globals = {
|
read_globals = {
|
||||||
|
string = {fields = {"split"}},
|
||||||
|
table = {fields = {"copy", "getn"}},
|
||||||
|
|
||||||
"default",
|
"default",
|
||||||
"mcl_sounds",
|
"mcl_sounds",
|
||||||
"ks_sounds",
|
"ks_sounds",
|
||||||
|
2
init.lua
2
init.lua
@ -12,6 +12,8 @@ xcompat.materials = dofile(modpath .. "/src/materials.lua")
|
|||||||
xcompat.textures = dofile(modpath .. "/src/textures.lua")
|
xcompat.textures = dofile(modpath .. "/src/textures.lua")
|
||||||
xcompat.functions = dofile(modpath .. "/src/functions.lua")
|
xcompat.functions = dofile(modpath .. "/src/functions.lua")
|
||||||
|
|
||||||
|
dofile(modpath .. "/src/groups.lua")
|
||||||
|
|
||||||
local function validate_sound(key)
|
local function validate_sound(key)
|
||||||
if key and xcompat.sounds[key] then
|
if key and xcompat.sounds[key] then
|
||||||
return true
|
return true
|
||||||
|
26
src/groups.lua
Normal file
26
src/groups.lua
Normal 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},
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user