Razara

makeRoom

Jan 17th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. tArgs = {...}
  2.  
  3. local length, height, width
  4. if #tArgs ~= 3 then
  5.     print("Invalid number of arguments. Needs x y z")
  6. else
  7.     length = tonumber(tArgs[1])
  8.     height = tonumber(tArgs[2])
  9.     width = tonumber(tArgs[3])
  10. end
  11.  
  12. local upHigh = false
  13. function digZ()
  14.     for z=1,height-1 do
  15.     if not upHigh then
  16.         while turtle.digUp() do sleep(0.5) end
  17.         turtle.up()
  18.     else
  19.         while turtle.digDown() do  end
  20.         turtle.down()
  21.     end
  22.     end
  23.     upHigh = not upHigh
  24. end
  25.  
  26. function digForward()
  27.     while turtle.dig() do sleep(0.5) end
  28.     turtle.forward()
  29. end
  30.  
  31.  
  32.  
  33. if length*width*height > turtle.getFuelLevel() then
  34.     print("Not enough fuel")
  35. else
  36.     digForward()
  37.     digZ()
  38.    
  39.     for y = 1,width do
  40.         for x = 1,length-1 do
  41.             digForward()
  42.             digZ()
  43.         end
  44.        
  45.         if y < width then
  46.             if y%2 ~= 0 then
  47.                 turtle.turnRight()
  48.                 digForward()
  49.                 digZ()
  50.                 turtle.turnRight()
  51.             else
  52.                 turtle.turnLeft()
  53.                 digForward()
  54.                 digZ()
  55.                 turtle.turnLeft()
  56.             end
  57.         end
  58.     end
  59.  
  60.     -- checks if the turtle ended up at the ceiling and sends it back to the floor
  61.     if upHigh then
  62.         while turtle.down() do end
  63.     end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment