From ca67ec4af64208df1123742cc90027c7c1cf987e Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 29 Dec 2022 23:19:05 +0000 Subject: shop --- shop.lua | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/shop.lua b/shop.lua index 6d313e5..f8de7ea 100644 --- a/shop.lua +++ b/shop.lua @@ -72,35 +72,42 @@ function proctrans(tr) tell(tostring(amt)) if amt>0 then - give(5) + give(1) tell("thank you!!! :3") end else - tell("that's the wrong about of money. please send "..PRICE.."kst. (todo: refund you)") + tell("that's the wrong about of money. please send "..PRICE.."kst.") if meta['return'] then - -- todo: refund + + end end end -while true do - msgtxt = assert(ws.receive(),"ws error") - msg = textutils.unserializeJSON(msgtxt) - if msg.type ~= "keepalive" then print(msgtxt) end - if msg.type == "response" and msg.responding_to_type == "me" then - our_addr = msg.address.address - local m = peripheral.wrap"left" - m.setCursorPos(1,1) - m.write(our_addr) - end - if msg.type == "event" and msg.event == "transaction" then - require"cc.pretty".pretty_print(proctrans(msg.transaction)) +function shop_run() + while true do + msgtxt = assert(ws.receive(),"ws error") + msg = textutils.unserializeJSON(msgtxt) + if msg.type ~= "keepalive" then print(msgtxt) end + if msg.type == "response" and msg.responding_to_type == "me" then + our_addr = msg.address.address + local m = peripheral.wrap"left" + m.setCursorPos(1,1) + m.write(our_addr) + end + if msg.type == "event" and msg.event == "transaction" then + require"cc.pretty".pretty_print(proctrans(msg.transaction)) + end end end +while true do + local ty=os.pullEvent() + print(ty) +end -- mtop = peripheral.wrap"top" -- while true do -- cgit v1.2.3