Fix make unrepairable (#25)
Due to a table reference in builtin, modifying the table directly affected other items as well. The function will now copy the values into a new table to replace the table reference.
This commit is contained in:
parent
c7cf2b48ab
commit
fd860bd0e9
9
init.lua
9
init.lua
@ -18,11 +18,14 @@ local hammer_repairable = minetest.settings:get_bool("anvil_hammer_is_repairable
|
||||
anvil.make_unrepairable = function(item_name)
|
||||
local item_def = minetest.registered_items[item_name]
|
||||
if item_def then
|
||||
item_def.groups.not_repaired_by_anvil = 1
|
||||
minetest.override_item(item_name, {groups = item_def.groups})
|
||||
-- Drop table reference. Copy other values over.
|
||||
local groups = { not_repaired_by_anvil = 1 }
|
||||
for k, v in pairs(item_def.groups) do groups[k] = v end
|
||||
minetest.override_item(item_name, {groups = groups})
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("technic") then
|
||||
-- make rechargeable technic tools unrepairable
|
||||
anvil.make_unrepairable("technic:water_can")
|
||||
anvil.make_unrepairable("technic:lava_can")
|
||||
@ -47,7 +50,7 @@ anvil.make_unrepairable("technic:mining_drill_mk3_2")
|
||||
anvil.make_unrepairable("technic:mining_drill_mk3_3")
|
||||
anvil.make_unrepairable("technic:mining_drill_mk3_4")
|
||||
anvil.make_unrepairable("technic:mining_drill_mk3_5")
|
||||
|
||||
end
|
||||
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user