Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local http = require("http")
- local function sendToServer(data)
- local response = http.post("http://localhost:3000/turtle", textutils.serialize(data))
- if response then
- print(response.readAll())
- else
- print("Failed to connect to server")
- end
- end
- while true do
- local command = http.get("http://localhost:3000/command")
- if command then
- local cmd = command.readAll()
- if cmd == "forward" then
- turtle.forward()
- elseif cmd == "back" then
- turtle.back()
- end
- sendToServer({x = turtle.getPosition().x, y = turtle.getPosition().y, z = turtle.getPosition().z})
- end
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement