Advertisement
Guest User

turtle

a guest
Aug 9th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local control = 111
  2. local objects = {"Turtle", "Dirt", "Sand", "Stone"}
  3.  
  4. rednet.open("right")
  5.  
  6. while true do
  7.     id, msg = rednet.receive()
  8.     if id == control then
  9.         command = loadstring(msg)
  10.         command()
  11.         front = "Unknown"
  12.         if turtle.detect() then
  13.             for i = 1, #objects do
  14.                 turtle.select(i)
  15.                 if turtle.compare() then
  16.                     front = objects[i]
  17.                     break
  18.                 end
  19.             end
  20.         else
  21.             front = "Air"
  22.         end
  23.         if front == "Turtle" then
  24.             turtle.dig()
  25.         end
  26.         up = "Unknown"
  27.         if turtle.detectUp() then
  28.             for i = 1, #objects do
  29.                 turtle.select(i)
  30.                 if turtle.compareUp() then
  31.                     up = objects[i]
  32.                     break
  33.                 end
  34.             end
  35.         else
  36.             up = "Unknown"
  37.         end
  38.         if up == "Turtle" then
  39.             turtle.digUp()
  40.         end
  41.         down = "Unknown"
  42.         if turtle.detectDown() then
  43.             for i = 1, #objects do
  44.                 turtle.select(i)
  45.                 if turtle.compareDown() then
  46.                     down = objects[i]
  47.                     break
  48.                 end
  49.             end
  50.         else
  51.             down = "Air"
  52.         end
  53.         if down == "Turtle" then
  54.             turtle.digDown()
  55.         end
  56.         toSend = textutils.serialize({r, front, up, down})
  57.         rednet.send(control, toSend)
  58.     end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement