nalc/nalc_lib/init.lua
sys4-fr d8016d3b71 Ajout du mod nalc_awards
Ce mod permet de limiter les crafts d'items. Pour l'instant les 2
types de quarry. Il faut obtenir certains awards pour avoir le droit
de crafter un certain nombre de quarries. Au total il est possible de
crafter 12 quarries et 4 super quarries au maximum par joueur.
2019-03-02 19:41:08 +01:00

52 lines
1.3 KiB
Lua

nalc = {}
-- Remove node from a group
local function remove_group(name, group)
local node = minetest.registered_nodes[name]
if node then
local groups = node.groups
if groups then
for g in pairs(groups) do
if g == group then
groups[g] = 0
minetest.log("action", "[nalc_lib] "..name.." removed from group "..group..".")
end
end
minetest.override_item(name, {groups = groups})
else
minetest.log("warning", "[nalc_lib] "..name.." has no groups, could not remove group "..group..".")
end
else
minetest.log("warning", "[nalc_lib] "..name.." not registered, could not remove group "..group..".")
end
end
-- Add node to group
function nalc.add_group(name, group, value)
local node = minetest.registered_nodes[name]
if node then
local groups = node.groups
if not groups then
groups = {}
end
groups[group] = value
minetest.log("action", "[nalc_lib] Add group "..group.."="..value.." to "..name)
minetest.override_item(name, {groups = groups})
end
end
-- Add a node in xp group
--function nalc.def_xp(name, value)
-- add_group(name, "xp", value)
--end
-- Remove node from group "oddly_breakable_by_hand"
--function nalc.not_hand_breakable(name)
-- remove_group(name, "oddly_breakable_by_hand")
--end
minetest.log("action", "[nalc_lib] loaded.")