Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function jsonCheck()
- if not fs.exists("json") then
- shell.run("pastebin get 4nRg9CHU json")
- end
- end
- jsonCheck()
- print("Press any key to start the turtle")
- local blah = read();
- os.loadAPI('json')
- local connectionURL = "ws://icantcraft.net:5757"
- local ws, err = http.websocket(connectionURL)
- local turtleCount = 0
- function placeBoxes()
- turtle.select(1)
- turtle.placeUp()
- turtle.forward()
- turtle.select(2)
- turtle.placeUp()
- turtle.back()
- end
- function placeTurtles()
- for i = 1, turtleCount do
- turtle.select(1)
- turtle.suckUp(1)
- turtle.place()
- os.sleep(1)
- peripheral.wrap("front")
- peripheral.call("front", "turnOn")
- os.sleep(5)
- end
- end
- if err then
- return printError(err)
- elseif ws then
- ws.send("master")
- while true do
- local _, url, res, isBinary = os.pullEvent("websocket_message")
- if url == connectionURL then
- local obj = json.decode(res)
- turtleCount = tonumber(obj.maxX) * tonumber(obj.maxY)
- print(turtleCount)
- placeBoxes()
- placeTurtles()
- ws.close()
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement