forked from Sokomine/yl_speak_up
sort the entries in the trade list
This commit is contained in:
parent
0c9d547401
commit
9c513d5fd1
@ -17,7 +17,7 @@ yl_speak_up.input_trade_list = function(player, formname, fields)
|
|||||||
if(fields.trade_list_add_trade) then
|
if(fields.trade_list_add_trade) then
|
||||||
-- show the trade config dialog for a new trade
|
-- show the trade config dialog for a new trade
|
||||||
minetest.show_formspec(pname, "yl_speak_up:add_trade_simple",
|
minetest.show_formspec(pname, "yl_speak_up:add_trade_simple",
|
||||||
yl_speak_up.get_fs_trade_simple(player, "new"))
|
yl_speak_up.get_fs_add_trade_simple(player, "new"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -79,8 +79,17 @@ yl_speak_up.get_fs_trade_list = function(player)
|
|||||||
local col = 0
|
local col = 0
|
||||||
local anz_trades = 0
|
local anz_trades = 0
|
||||||
|
|
||||||
|
-- the order in which the trades appear shall not change each time;
|
||||||
|
-- but lua cannot sort the keys of a table by itself...
|
||||||
|
local sorted_trades = {}
|
||||||
|
for k in pairs(dialog.trades) do
|
||||||
|
table.insert(sorted_trades, k)
|
||||||
|
end
|
||||||
|
table.sort(sorted_trades)
|
||||||
|
|
||||||
-- TODO: handle multiple pages?
|
-- TODO: handle multiple pages?
|
||||||
for k, v in pairs(dialog.trades) do
|
for i, k in ipairs(sorted_trades) do
|
||||||
|
v = dialog.trades[ k ]
|
||||||
if(col < yl_speak_up.trade_max_cols
|
if(col < yl_speak_up.trade_max_cols
|
||||||
and v.pay and v.pay[1] and v.pay[1] ~= "" and v.buy and v.buy[1] and v.buy[1] ~= "") then
|
and v.pay and v.pay[1] and v.pay[1] ~= "" and v.buy and v.buy[1] and v.buy[1] ~= "") then
|
||||||
local pay_stack = ItemStack(v.pay[1])
|
local pay_stack = ItemStack(v.pay[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user