caucow

vquarry

Dec 28th, 2016 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. local function tryRefuel()
  2.   while turtle.getFuelLevel() < 1 do
  3.     for i = 1, 16 do
  4.       turtle.select(i)
  5.       turtle.refuel(1)
  6.       if turtle.getFuelLevel() > 0 then
  7.         break
  8.       end
  9.     end
  10.     turtle.select(1)
  11.   end
  12. end
  13.  
  14. local function up()
  15.   tryRefuel()
  16.   while not turtle.up() do
  17.     turtle.digUp()
  18.   end
  19. end
  20.  
  21. local function down()
  22.   tryRefuel()
  23.   while not turtle.down() do
  24.     turtle.digDown()
  25.   end
  26. end
  27.  
  28. local function forward()
  29.   tryRefuel()
  30.   while not turtle.forward() do
  31.     turtle.dig()
  32.   end
  33. end
  34.  
  35. local function xforward(dist)
  36.   for i = 1, dist do
  37.     forward()
  38.     turtle.digUp()
  39.     turtle.digDown()
  40.   end
  41. end
  42.  
  43. local function rCorner()
  44.   turtle.turnRight()
  45.   turtle.dig()
  46.   forward()
  47.   turtle.digUp()
  48.   turtle.digDown()
  49.   turtle.turnRight()
  50. end
  51.  
  52. local function lCorner()
  53.   turtle.turnLeft()
  54.   turtle.dig()
  55.   forward()
  56.   turtle.digUp()
  57.   turtle.digDown()
  58.   turtle.turnLeft()
  59. end
  60.  
  61. local size, height = ...
  62. if size == nil or height == nil then
  63.   print("Usage: vquarry <size> <height>")
  64.   print("Height should be a multiple of 3.")
  65.   return
  66. end
  67. size = tonumber(size)
  68. height = tonumber(height)
  69. if height < 3 then
  70.   print("Height must be at least 3.")
  71.   return
  72. end
  73.  
  74. turtle.digUp()
  75. turtle.digDown()
  76. for y = 3, height, 3 do
  77.   for x = 1, size do
  78.     xforward(size - 1)
  79.     if x == size then
  80.       turtle.turnRight()
  81.       if size % 2 == 1 then
  82.         turtle.turnRight()
  83.       end
  84.       if y + 3 <= height then
  85.         for i = 1, 3 do
  86.           up()
  87.         end
  88.         turtle.digUp()
  89.       end
  90.     elseif x % 2 == 1 then
  91.       rCorner()
  92.     else
  93.       lCorner()
  94.     end
  95.   end
  96. end
  97. for y = 4, height, 3 do
  98.   for i = 1, 3 do
  99.     down()
  100.   end
  101. end
Add Comment
Please, Sign In to add comment