[Solved] Trying to add a group for an existing node

Posted:
Wed Feb 01, 2017 21:58
by yawin
Hello! I'm trying to add a group to an existing node (without overwriting the groups I already have) and the only way I can think of is this:
minetest.override_item("default:stone", {
groups.magical_tier1 = 1,
})
But it does not work. Does anyone comes up with something?
Re: Trying to add a group for an existing node

Posted:
Wed Feb 01, 2017 23:50
by duane
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- Modify a node to add a group
function minetest.add_group(node, groups)
local def = minetest.registered_items[node]
if not def then
return false
end
local def_groups = def.groups or {}
for group, value in pairs(groups) do
if value ~= 0 then
def_groups[group] = value
else
def_groups[group] = nil
end
end
minetest.override_item(node, {groups = def_groups})
return true
end
From
Valleys Mapgen (GPL3).