Advertisement
djgaven588

Remote Turtle Control - Pocket Computer

Feb 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. rednet.open('back')
  2. turtleId = 0
  3.  
  4. function ClearScreen()
  5.     term.clear()
  6.     term.setCursorPos(1,1)
  7.     print("W = Forward, S = Backward")
  8.     print("A = Left, D = Right")
  9.     print("Q = Up, E = Down")
  10.     print("Dig = Dig, DigUp = Dig Up, DigDown = Dig Down")
  11.     print("Run (program) = Run Program")
  12. end
  13.  
  14. function SendCommand(cmd)
  15.     rednet.send(turtleId, cmd)
  16.     ClearScreen()
  17.     print(cmd)
  18. end
  19.  
  20. ClearScreen()
  21.  
  22. while true do
  23.     input = read()
  24.     if input == "w" then
  25.         SendCommand("turtle.forward()")
  26.     elseif input == "s" then
  27.         SendCommand("turtle.backward()")
  28.     elseif input == "a" then
  29.         SendCommand("turtle.turnLeft()")
  30.     elseif input == "d" then
  31.         SendCommand("turtle.turnRight()")
  32.     elseif input == "q" then
  33.         SendCommand("turtle.up()")
  34.     elseif input == "E" then
  35.         SendCommand("turtle.down()")
  36.     elseif input == "dig" then
  37.         SendCommand("turtle.dig()")
  38.     elseif input == "digUp" then
  39.         SendCommand("turtle.digUp()")
  40.     elseif input == "digDown" then
  41.         SendCommand("turtle.digDown()")
  42.     elseif string.find(input, "run")then
  43.         SendCommand(string.sub(input, 5))
  44.     end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement