strip newlines from tools in death messages

Players naming their tools with newlines can mess up chat with death
messages. This commit strips out newlines (\r and \n ) in the tool
name for death messages.
This commit is contained in:
cora 2021-11-29 12:52:06 +01:00 committed by Gitea
parent c08f9850f6
commit 5252952555

View file

@ -3,11 +3,11 @@ local N = function(s) return s end
local function get_tool_name(item)
local name = item:get_meta():get_string("name")
if name ~= "" then
return name
end
if name == "" then
local def = item:get_definition()
return def._tt_original_description or def.description
name=def._tt_original_description or def.description
end
return name:gsub("[\r\n]"," ")
end
mcl_death_messages = {}