From 0d59ecdd2b9715b20e6cba6c0ea79a74af15a1d7 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 7 Jan 2023 05:29:58 +0000 Subject: shop2 --- shop2/disp.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'shop2') diff --git a/shop2/disp.lua b/shop2/disp.lua index 9417dfe..a2fad5e 100644 --- a/shop2/disp.lua +++ b/shop2/disp.lua @@ -43,24 +43,15 @@ local function disp_shopscreen(items) -- 123456789012345678901234567890123456789012345678901234567 -- 0 1 2 3 4 5 - -- local function fmt_row(m,y, stock,price,adr,name, colour) - local function fmt_row(y, idesc, amt, colour) - colour = colour or colors.cyan - printseq(mon) { - {1,y}, colors.white, pad(amt,5), - {8,y}, colors.yellow, pad(idesc.price,3), colors.lightGray, "kst", - {16,y}, colour, idesc.adr, - {22,y}, colour, idesc.hname, - } - end - - -- sort alphabetically by address -- todo: more intuitive sort, once more things are for sale local adrs = {} for adr in pairs(items) do table.insert(adrs,adr) end table.sort(adrs) - + + + -- do all processing and counting BEFORE clearing monitor + -- to avoid flickering mon.clear() mon.setTextScale(0.5) @@ -69,6 +60,15 @@ local function disp_shopscreen(items) {1,2}, colors.lightGray, "Stock Price Adr. Name", } + local function fmt_row(y, idesc, amt, colour) + colour = colour or colors.cyan + printseq(mon) { + {1,y}, colors.white, pad(amt,5), + {8,y}, colors.yellow, pad(idesc.price,3), colors.lightGray, "kst", + {16,y}, colour, idesc.adr, + {22,y}, colour, idesc.hname, + } + end for ix,adr in ipairs(adrs) do local idesc = items[adr] fmt_row(ix+2, idesc) -- cgit v1.2.3