Improve market summary displaying long item names

This commit is contained in:
bri cassa 2021-04-11 11:59:43 +02:00
parent 9c8f62320e
commit 6989f6a00e
2 changed files with 5 additions and 4 deletions

View File

@ -14,8 +14,8 @@ local function split(str, sep)
local regex = ("([^%s]+)"):format(sep)
for each in str:gmatch(regex) do
local sub = nil
if #each > 25 then
sub = string.sub(each, 1, 25).."..."
if #each > 34 then
sub = string.sub(each, 1, 34).."..."
end
table.insert(result, sub or each)
end
@ -51,8 +51,8 @@ local function mk_summary_fs()
local all_items = minetest.registered_items
for i, row in ipairs(exchange:market_summary()) do
local def = all_items[row.Item] or {}
add_row(row.Item,
split(def.description, "\n")[1] or S("Unknown Item"),
add_row(#row.Item > 24 and string.sub(row.Item, 1, 24).."..." or row.Item,
split(def.description, "\n")[1] or S("No description"),
wear_string(row.Wear),
row.Buy_Volume or 0,
row.Buy_Max or "N/A",

View File

@ -53,6 +53,7 @@ Buy Max=Achat Max
Sell Vol=Qté vente
Sell Min=Vente Min
Unknown Item=Item inconnue
No description=Pas de description
New (-0%)=Neuf (-0%)
Good (-10%)=Bon (-10%)
Worn (-50%)=Usé (-50%)