Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if os.loadAPI("turtleCar") then
- -- compass = peripheral.find("compass")
- modem = peripheral.find("modem")
- modem.open(55)
- actions = 0
- while true do
- term.clear()
- term.setCursorPos(1, 1)
- -- dir = turtleCar.getDir(compass)
- -- coords = turtleCar.getCoords()
- -- print("Turtle is currently facing "..dir)
- -- print("Turtle is at "..coords[1]..", "..coords[2]..", "..coords[3])
- print("Performed "..actions.." actions")
- e, side, sendCh, replyCh, msg, dist = os.pullEvent("modem_message")
- if msg == "l" then
- turtleCar.left()
- actions = actions + 1
- elseif msg == "r" then
- turtleCar.right()
- actions = actions + 1
- elseif msg == "u" then
- turtleCar.up()
- actions = actions + 1
- elseif msg == "d" then
- turtleCar.down()
- actions = actions + 1
- elseif msg == "update" then
- shell.run("updateCar")
- elseif (tonumber(msg) > 0) or (tonumber(msg) < 0) then
- if msg > 0 then
- turtleCar.forward(msg)
- actions = actions + 1
- elseif msg < 0 then
- turtleCar.backward((msg * -1))
- actions = actions + 1
- end
- end
- msg = nil
- -- turtleCar.writeCoords(coords)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement