From fe3b4c80df0ca3220743ac0c5163e625b2775903 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Mon, 5 Sep 2022 07:08:55 +0200 Subject: [PATCH] sort trade limit list by item name --- fs_trade_limit.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs_trade_limit.lua b/fs_trade_limit.lua index e7aab12..4207ef4 100644 --- a/fs_trade_limit.lua +++ b/fs_trade_limit.lua @@ -176,11 +176,16 @@ yl_speak_up.get_fs_trade_limit = function(player, selected) -- the table event selection returns a row index - we need to translate that to our table local item_list = {} - local row = 2 - local selected_row = 1 - -- TODO: sort this list in some way? alphabeticly? by limit? + local descr_list = {} for k,v in pairs( items ) do table.insert(item_list, k) + end + -- avoid total chaos by sorting this list + table.sort(item_list) + local row = 2 + local selected_row = 1 + for i, k in ipairs( item_list ) do + local v = items[k] if(selected and k == selected) then selected_row = #item_list + 1 end