From 7c1e625451d30db2f5f135f149585ff54c31bd4c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 2 Feb 2018 05:40:22 +0100 Subject: [PATCH] Allow to clear name with anvil --- mods/ITEMS/mcl_anvils/init.lua | 39 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index fbc223aa..8b38ac41 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -31,28 +31,27 @@ local function update_anvil_slots(meta) -- Just rename if (not input1:is_empty() and input2:is_empty()) or (input1:is_empty() and not input2:is_empty()) then - if new_name ~= nil and new_name ~= "" then - local name_item - if input1:is_empty() then - name_item = input2 - else - name_item = input1 - end - -- No renaming allowed with group no_rename=1 - if minetest.get_item_group(name_item:get_name(), "no_rename") == 1 then - new_output = "" - else - local meta = name_item:get_meta() - -- Limit name length - new_name = string.sub(new_name, 1, 30) - -- Rename item - meta:set_string("description", new_name) - -- Double-save the name internally, too - meta:set_string("name", new_name) - new_output = name_item - end + if new_name == nil then + new_name = "" + end + local name_item + if input1:is_empty() then + name_item = input2 else + name_item = input1 + end + -- No renaming allowed with group no_rename=1 + if minetest.get_item_group(name_item:get_name(), "no_rename") == 1 then new_output = "" + else + local meta = name_item:get_meta() + -- Limit name length + new_name = string.sub(new_name, 1, 30) + -- Rename item + meta:set_string("description", new_name) + -- Double-save the name internally, too + meta:set_string("name", new_name) + new_output = name_item end else new_output = ""