diff options
author | ubq323 <ubq323@ubq323.website> | 2022-12-29 23:19:05 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2022-12-29 23:19:05 +0000 |
commit | ca67ec4af64208df1123742cc90027c7c1cf987e (patch) | |
tree | 46d43c4e23f75336e179fccca0df450c778f1ee6 | |
parent | 0a1c63ea7759911cb010431d916b519e81d11251 (diff) |
shop
-rw-r--r-- | shop.lua | 37 |
1 files changed, 22 insertions, 15 deletions
@@ -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 |