expose make_unrepairable

master
FaceDeer 2020-02-16 22:02:48 -07:00
parent a6fa5984e2
commit 6969e7baff
2 changed files with 8 additions and 4 deletions

View File

@ -2,4 +2,8 @@ Anvil mod by Sokomine, originally a part of the Cottages mod but extracted to st
This anvil (and its associated hammer) allows a player to repair worn tools. Place the worn tool in the anvil's inventory and strike it with the hammer to improve its condition.
By default, a hammer can be repaired on the anvil just like any other tool, allowing for infinite recycling of worn tools. Set "anvil_hammer_is_repairable false" to prevent this.
By default, a hammer can be repaired on the anvil just like any other tool, allowing for infinite recycling of worn tools. Set "anvil_hammer_is_repairable false" to prevent this.
Any tool belonging to the group "not_repaired_by_anvil" can't be repaired at an anvil.
The API function anvil.make_unrepairable(item_name) can be used as a convenience function to add this group to an already-registered tool.

View File

@ -16,15 +16,15 @@ minetest.register_alias("castle:anvil", "anvil:anvil")
local hammer_repairable = minetest.setting_getbool("anvil_hammer_is_repairable")
if hammer_repairable == nil then hammer_repairable = true end
local make_unrepairable = function(item_name)
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})
end
end
make_unrepairable("technic:water_can")
make_unrepairable("technic:lava_can")
anvil.make_unrepairable("technic:water_can")
anvil.make_unrepairable("technic:lava_can")
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())