1
0
Fork 0

Allow to clear name with anvil

This commit is contained in:
Wuzzy 2018-02-02 05:40:22 +01:00
parent 86b7f537d5
commit 7c1e625451
1 changed files with 19 additions and 20 deletions

View File

@ -31,28 +31,27 @@ local function update_anvil_slots(meta)
-- Just rename -- Just rename
if (not input1:is_empty() and input2:is_empty()) or (input1:is_empty() and not input2:is_empty()) then 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 if new_name == nil then
local name_item new_name = ""
if input1:is_empty() then end
name_item = input2 local name_item
else if input1:is_empty() then
name_item = input1 name_item = input2
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 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 = "" 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 end
else else
new_output = "" new_output = ""