spdkils

ComputerCraft Remote Turtle

May 11th, 2021
1,059
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local sender = 1
  2.  
  3. shell.run('clear')
  4. rednet.open("left")
  5. local function tryDown()
  6.     while not turtle.down() do
  7.         turtle.digDown()
  8.         return "Dig Down"
  9.     end
  10.     return true
  11. end
  12. local function tryUp()
  13.     while not turtle.up() do
  14.         turtle.digUp()
  15.         return "Dig Up"
  16.     end
  17.     return true
  18. end
  19. local function tryInspect()
  20.     local obj, thing = turtle.inspect()
  21.     if obj then return thing.name end
  22.     return "Air"
  23. end
  24. local actions = {}
  25. actions["forward"] = turtle.forward
  26. actions["backward"] = turtle.back
  27. actions["left"] = turtle.turnLeft
  28. actions["right"] = turtle.turnRight
  29. actions["up"] = tryUp
  30. actions["down"] = tryDown
  31. actions["dig"] = turtle.dig
  32. actions["place"] = turtle.place
  33. actions["inspect"] = tryInspect
  34. while true do
  35.     local action, senderID, text = os.pullEvent("rednet_message")
  36.     if actions[text] then
  37.         local a, b, c = actions[text]()
  38.         rednet.send(1, a)
  39.     end
  40. end
  41.  
RAW Paste Data