summaryrefslogtreecommitdiff
path: root/shop.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2022-12-29 23:19:05 +0000
committerubq323 <ubq323@ubq323.website>2022-12-29 23:19:05 +0000
commitca67ec4af64208df1123742cc90027c7c1cf987e (patch)
tree46d43c4e23f75336e179fccca0df450c778f1ee6 /shop.lua
parent0a1c63ea7759911cb010431d916b519e81d11251 (diff)
shop
Diffstat (limited to 'shop.lua')
-rw-r--r--shop.lua37
1 files 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