diff options
-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 |