From c18661a230dae15ce3056604173c468687ce908d Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 30 Dec 2022 00:08:24 +0000 Subject: shop --- shop.lua | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/shop.lua b/shop.lua index 7f986c9..ea05a85 100644 --- a/shop.lua +++ b/shop.lua @@ -127,8 +127,8 @@ end function run_sidedisp() local m = peripheral.wrap("left") - m.clear() local function printseq(q) + m.clear() for _,v in ipairs(q) do if type(v) == "number" then m.setTextColor(v) @@ -140,14 +140,26 @@ function run_sidedisp() end end while true do + local sa = stock_amt() printseq { {7,1}, colors.orange, "UBQ323", {3,2}, "DIAMOND STORE", {9,3}, "!!!", - {1,5}, colors.white, "Stock: ", colors.yellow, ""..stock_amt(), - {1,6}, colors.white, "Price: ", colors.yellow, ""..PRICE, colors.white, "kst/item", - {2,8}, colors.blue, "/pay d@ac.kst "..PRICE + {1,5}, colors.white, "Stock: ", colors.yellow, ""..sa, + {1,6}, colors.white, "Price: ", colors.yellow, ""..PRICE, colors.white, "kst/item" } - os.sleep(5) + if sa > 0 then + printseq { + {2,8}, colors.blue, "/pay d@ac.kst "..PRICE, + {2,9}, colors.grey, "(or a multiple of "..PRICE..")", + } + else + printseq { + {2,8}, colors.red, "Out of stock!", + {2,9}, "please come back soon", + } + + end + os.sleep(2) end end -- cgit v1.2.3