Item names are now working correctly

This commit is contained in:
fmmaks 2023-10-11 22:19:57 +03:00 committed by GitHub
parent f491b850ef
commit db864cc9d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -62,6 +62,7 @@ minetest.register_globalstep(function(dtime)
data.itemname = itemname
data.index = index
data.dtime = 0
local lang_code = minetest.get_player_information(player:get_player_name()).lang_code
local desc = stack.get_meta
and stack:get_meta():get_string("description")
@ -74,10 +75,10 @@ minetest.register_globalstep(function(dtime)
if only_names and desc and string.find(desc, "\n") then
desc = string.match(desc, "([^\n]*)")
end
if not (max_length <= 0) and string.len(desc) > max_length then
desc = minetest.strip_colors(desc) -- FIXME: @default) is not getting removed
desc = string.sub(desc, 1 , max_length) .. " [...]"
desc = minetest.get_translated_string(lang_code, desc)
desc = minetest.strip_colors(desc)
if string.len(desc) > max_length and max_length > 0 then
desc = string.sub(desc, 1, max_length) .. " [...]"
end
player:hud_change(data.hud, 'text', desc)
end