From f1057c0542e6b592e7b9e30681d7409877ea1a51 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 2 Feb 2018 05:42:35 +0100 Subject: [PATCH] Enforce anvil name length more strictly --- mods/ITEMS/mcl_anvils/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index 8b38ac416d..f5dca97eee 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -1,3 +1,5 @@ +local MAX_NAME_LENGTH = 30 + local function get_anvil_formspec(set_name) if not set_name then set_name = "" @@ -46,7 +48,7 @@ local function update_anvil_slots(meta) else local meta = name_item:get_meta() -- Limit name length - new_name = string.sub(new_name, 1, 30) + new_name = string.sub(new_name, 1, MAX_NAME_LENGTH) -- Rename item meta:set_string("description", new_name) -- Double-save the name internally, too @@ -159,6 +161,8 @@ local anvildef = { set_name = fields.name end local meta = minetest.get_meta(pos) + -- Limit name length + set_name = string.sub(set_name, 1, MAX_NAME_LENGTH) meta:set_string("set_name", set_name) update_anvil_slots(meta) meta:set_string("formspec", get_anvil_formspec(set_name))