From 1afe90430347aa6beeefa97f6c5d44fb80f21616 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Wed, 24 Feb 2021 02:28:59 +0100 Subject: [PATCH] added cottages.forbid_repair to allow forbidding some tools from beeing repaired --- nodes_anvil.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nodes_anvil.lua b/nodes_anvil.lua index cfe04c3..0b7149c 100644 --- a/nodes_anvil.lua +++ b/nodes_anvil.lua @@ -9,6 +9,12 @@ local S = cottages.S +-- disable repair with anvil by setting a message for the item in question +cottages.forbid_repair = {} +-- example for hammer no longer beeing able to repair the hammer +--cottages.forbid_repair["cottages:hammer"] = 'The hammer is too complex for repairing.' + + -- the hammer for the anvil minetest.register_tool("cottages:hammer", { description = S("Steel hammer for repairing tools on the anvil"), @@ -138,6 +144,12 @@ minetest.register_node("cottages:anvil", { S('The workpiece slot is for damaged tools only.')); return 0; end + if( listname=='input' + and cottages.forbid_repair[ stack:get_name() ]) then + minetest.chat_send_player( player:get_player_name(), + S(cottages.forbid_repair[ stack:get_name() ])); + return 0; + end return stack:get_count() end, @@ -181,6 +193,14 @@ minetest.register_node("cottages:anvil", { -- 65535 is max damage local damage_state = 40-math.floor(input:get_wear()/1638); + -- just to make sure that it really can't get repaired if it should not + -- (if the check of placing the item in the input slot failed somehow) + if( puncher and name and cottages.forbid_repair[ input:get_name() ]) then + minetest.chat_send_player( name, + S(cottages.forbid_repair[ input:get_name() ])); + return; + end + local tool_name = input:get_name(); local hud_image = ""; if( tool_name