From 26b6476d2f5a87d011ec40c57f9b678adc6cd70b Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Fri, 8 Sep 2023 09:31:17 +0200 Subject: [PATCH 1/4] Fix anvil bug --- nodes_anvil.lua | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/nodes_anvil.lua b/nodes_anvil.lua index 0b7149c..f27aa11 100644 --- a/nodes_anvil.lua +++ b/nodes_anvil.lua @@ -9,12 +9,6 @@ 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"), @@ -144,12 +138,6 @@ 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, @@ -193,14 +181,6 @@ 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 @@ -249,9 +229,15 @@ minetest.register_node("cottages:anvil", { end minetest.after(2, function() if( puncher ) then - if(hud1) then puncher:hud_remove(hud1); end - if(hud2) then puncher:hud_remove(hud2); end - if(hud3) then puncher:hud_remove(hud3); end + if( hud1 ) then + puncher:hud_remove(hud1); + end + if( hud2 ) then + puncher:hud_remove(hud2); + end + if( hud3 ) then + puncher:hud_remove(hud3); + end end end) From efabbb6c835d0b7dbb9c9ee60d7562c695948065 Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Fri, 8 Sep 2023 09:54:26 +0200 Subject: [PATCH 2/4] Revert involuntary changes --- nodes_anvil.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nodes_anvil.lua b/nodes_anvil.lua index f27aa11..5cf02fb 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 From 7a9e2657f15afcccee237a970fe2459b8f98a1df Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Fri, 8 Sep 2023 09:56:26 +0200 Subject: [PATCH 3/4] Revert remaining involuntary changes --- nodes_anvil.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nodes_anvil.lua b/nodes_anvil.lua index 5cf02fb..de52e08 100644 --- a/nodes_anvil.lua +++ b/nodes_anvil.lua @@ -145,10 +145,10 @@ minetest.register_node("cottages:anvil", { 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; + 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, From a0d418820ac8daf74e1119deac93cba003996218 Mon Sep 17 00:00:00 2001 From: gabriel1379 Date: Fri, 8 Sep 2023 18:51:24 +0200 Subject: [PATCH 4/4] Fix indents --- nodes_anvil.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes_anvil.lua b/nodes_anvil.lua index de52e08..f99b8d1 100644 --- a/nodes_anvil.lua +++ b/nodes_anvil.lua @@ -249,7 +249,7 @@ minetest.register_node("cottages:anvil", { end minetest.after(2, function() if( puncher ) then - if( hud1 ) then + if( hud1 ) then puncher:hud_remove(hud1); end if( hud2 ) then