forked from nalc/global_exchange
Affiche seulement la première ligne de la description des items
This commit is contained in:
parent
81517a5b3d
commit
57deb8582e
@ -5,6 +5,17 @@ local summary_interval = 600
|
||||
|
||||
local global_inv = nil
|
||||
|
||||
-- NALC split() function
|
||||
local function split(str, sep)
|
||||
if not str then return nil end
|
||||
local result = {}
|
||||
local regex = ("([^%s]+)"):format(sep)
|
||||
for each in str:gmatch(regex) do
|
||||
table.insert(result, each)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
local function is_integer(x)
|
||||
return math.floor(x) == x
|
||||
end
|
||||
@ -35,7 +46,7 @@ local function mk_summary_fs()
|
||||
for i, row in ipairs(exchange:market_summary()) do
|
||||
local def = all_items[row.Item] or {}
|
||||
add_row(row.Item,
|
||||
def.description or "Unknown Item",
|
||||
split(def.description, "\n")[1] or "Unknown Item",
|
||||
wear_string(row.Wear),
|
||||
row.Buy_Volume or 0,
|
||||
row.Buy_Max or "N/A",
|
||||
@ -106,7 +117,7 @@ local selectable_list = {}
|
||||
minetest.after(0, function()
|
||||
for name, def in pairs(minetest.registered_items) do
|
||||
if (def.groups.not_in_creative_inventory or 0) == 0 and
|
||||
(def.description or "") ~= "" then
|
||||
(split(def.description, "\n")[1] or "") ~= "" then
|
||||
selectable_list[#selectable_list + 1] = name
|
||||
end
|
||||
end
|
||||
@ -128,7 +139,7 @@ local function table_from_results(fs, results, name, x, y, w, h, selected)
|
||||
for i, row in ipairs(results) do
|
||||
local def = all_items[row.Item] or {}
|
||||
add_row(row.Poster, row.Type, row.Item,
|
||||
def.description or "Unknown Item",
|
||||
split(def.description, "\n")[1] or "Unknown Item",
|
||||
wear_string(row.Wear), row.Amount, row.Rate)
|
||||
end
|
||||
end, math.max(0, tonumber(selected) or 0) + 1)
|
||||
|
Loading…
Reference in New Issue
Block a user