summaryrefslogtreecommitdiff
path: root/shop.lua
blob: 1ded4f640147d1c34251cdf8838185d43fe8ff5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
sres =textutils.unserializeJSON( http.post("https://krist.dev/ws/start","").readAll())
assert(sres.ok,"not ok")

ws = assert(http.websocket(sres.url))
nextid = 0

function sendws(t)
	t.id = nextid
	nextid = nextid + 1
	return ws.send(textutils.serializeJSON(t))
end
sendws { type="get_subscription_level" }

while true do
	msgtxt = assert(ws.receive(),"ws error")
	msg = textutils.unserializeJSON(msgtxt)
	print(msg.type)
	if msg.type ~= "keepalive" then print(msgtxt) end
end


-- mtop = peripheral.wrap"top"
-- while true do
-- mtop.setTextScale(3.5)
-- mtop.setTextColor(colors.cyan)
-- mtop.setCursorPos(1,1)
-- mtop.write"DIAMONDS"

-- os.sleep(0.75)
-- mtop.clear()
-- os.sleep(0.25)

-- mtop.setTextScale(3)
-- mtop.setTextColor(colors.white)
-- mtop.setCursorPos(1,1)
-- mtop.write("5KST EACH")

-- os.sleep(0.75)
-- mtop.clear()
-- os.sleep(0.25)

-- end