Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- turtleID = 235
- up = " "
- front = " "
- down = " "
- actions = {}
- start = 1
- while true do
- term.clear()
- for i = 1, #actions do
- print(actions[i])
- end
- term.setCursorPos(1,1)
- term.clearLine()
- print("Turtle mission control")
- term.setCursorPos(1,2)
- term.clearLine()
- print(" ")
- term.setCursorPos(1,3)
- term.clearLine()
- print(up)
- term.setCursorPos(1,4)
- term.clearLine()
- print(front)
- term.setCursorPos(1,5)
- term.clearLine()
- print(down)
- term.setCursorPos(1,6)
- term.clearLine()
- print(" ")
- while true do
- event, key = os.pullEvent("key")
- if key == keys.w then
- action = "forward"
- rednet.send(turtleID, "ret = turtle.forward()")
- break
- elseif key == keys.a then
- action = "left"
- rednet.send(turtleID, "ret = turtle.turnLeft()")
- break
- elseif key == keys.s then
- action = "back"
- rednet.send(turtleID, "ret = turtle.back()")
- break
- elseif key == keys.d then
- action = "right"
- rednet.send(turtleID, "ret = turtle.turnRight()")
- break
- elseif key == 42 then
- action = "down"
- rednet.send(turtleID, "ret = turtle.down()")
- break
- elseif key == 57 then
- action = "up"
- rednet.send(turtleID, "ret = turtle.up()")
- break
- elseif key == 28 then
- action = "dig"
- rednet.send(turtleID, "ret = turtle.dig()")
- break
- elseif key == keys.up then
- action = "dig up"
- rednet.send(turtleID, "ret = turtle.digUp()")
- break
- elseif key == keys.down then
- action = "dig down"
- rednet.send(turtleID, "ret = turtle.digDown()")
- break
- end
- end
- startClock = os.clock()
- success = false
- while os.clock() - startClock < 3 do
- id, msg = rednet.receive(1)
- if id == turtleID then
- success = true
- break
- end
- end
- if not success then error("Connection lost!") end
- receiving = textutils.unserialize(msg)
- r = receiving[1]
- front = receiving[2]
- up = receiving[3]
- down = receiving[4]
- if r then
- table.insert(actions, action)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement