immibis

turtle (1.3 pr2; requires "sandbox")

Feb 10th, 2012
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. -- starts just above -X -Y -Z facing +X
  2. -- ends just above +X +Y +Z facing +X
  3.  
  4. local facingy = false
  5.  
  6. local function travel(dx, dy, dz)
  7.     for k = 1, dz do turtle.up() end
  8.     if dy ~= 0 then
  9.         if not facingy then turtle.turnLeft() facingy=true end
  10.         for k = 1, dy do turtle.forward() end
  11.         for k = 1, -dy do turtle.back() end
  12.     end
  13.     if dx ~= 0 then
  14.         if facingy then turtle.turnRight() facingy=false end
  15.         for k = 1, dx do turtle.forward() end
  16.         for k = 1, -dx do turtle.back() end
  17.     end
  18.     for k = 1, -dz do turtle.down() end
  19. end
  20.  
  21. local function goto(x, y, z)
  22.     local tx, ty, tz = turtle.gps()
  23.     travel(x - tx, y - ty, z - tz)
  24. end
  25.  
  26. local function make(size)
  27.     if size == 1 then
  28.         while not turtle.placeDown() do
  29.             print("Out of blocks - refill and press enter!")
  30.             read()
  31.         end
  32.         return
  33.     end
  34.     size=size/3
  35.     local x, y, z = turtle.gps()
  36.     local d = size - 1
  37.     goto(x, y, z) make(size)
  38.     goto(x+size, y, z) make(size)
  39.     goto(x+size*2, y, z) make(size)
  40.     goto(x+size*2, y+size, z) make(size)
  41.     goto(x+size*2, y+size*2, z) make(size)
  42.     goto(x+size, y+size*2, z) make(size)
  43.     goto(x, y+size*2, z) make(size)
  44.     goto(x, y+size, z) make(size)
  45.     z = z + size
  46.     goto(x, y, z) make(size)
  47.     goto(x+size*2, y, z) make(size)
  48.     goto(x+size*2, y+size*2, z) make(size)
  49.     goto(x, y+size*2, z) make(size)
  50.     z = z + size
  51.     goto(x, y+size*2, z) make(size)
  52.     goto(x, y+size, z) make(size)
  53.     goto(x, y, z) make(size)
  54.     goto(x+size, y, z) make(size)
  55.     goto(x+size*2, y, z) make(size)
  56.     goto(x+size*2, y+size, z) make(size)
  57.     goto(x+size*2, y+size*2, z) make(size)
  58.     goto(x+size, y+size*2, z) make(size)
  59. end
  60.  
  61. make(81)
Advertisement
Add Comment
Please, Sign In to add comment