Advertisement
Guest User

rectexc (int, int, int)

a guest
Feb 27th, 2013
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.03 KB | None | 0 0
  1. function move()
  2.     if (turtle.getItemCount(16) ~= 0) then
  3.         dropItems()
  4.     end
  5.     if(turtle.getFuelLevel() == 0) then
  6.         error("Out of fuel")
  7.     end
  8.     while (not turtle.forward()) do
  9.         turtle.dig()
  10.     end
  11. end
  12.  
  13. function right()
  14.     turtle.turnRight()
  15. end
  16.  
  17. function left()
  18.     turtle.turnLeft()
  19. end
  20.  
  21. function down()
  22.     turtle.digDown()
  23.     turtle.down()
  24. end
  25.  
  26. function outer()
  27.     digside1()
  28.     right()
  29.     digside2()
  30.     right()
  31.     digside1()
  32.     right()
  33. end
  34.  
  35. function digside1()
  36.     for num = 2, side1 do
  37.         move()
  38.     end
  39. end
  40.  
  41. function digside2()
  42.     for num = 2, side2 do
  43.         move()
  44.     end
  45. end
  46.  
  47. function inner()
  48.     peaks = (side2 / 2) - 1
  49.     for num = 1, peaks do
  50.         ascend()
  51.         descend()
  52.     end
  53.     move()
  54.     right()
  55.     if(oddSide) then
  56.         oddSideFix()
  57.     end
  58. end
  59.  
  60. function ascend()
  61.     move()
  62.     right()
  63.     for num = 3, side1 do
  64.         move()
  65.     end
  66.     left()
  67. end
  68.  
  69. function descend()
  70.     move()
  71.     left()
  72.     for num = 3, side1 do
  73.         move()
  74.     end
  75.     right()
  76. end
  77.  
  78. function oddSideFix()
  79.     for num = 3, side1 do
  80.         move()
  81.     end
  82.     left()
  83.     left()
  84.     for num = 3, side1 do
  85.         move()
  86.     end
  87.     right()
  88.     move()
  89.     right()
  90. end
  91.  
  92. function dropItems()
  93.     right()
  94.     right()
  95.     turtle.select(1)
  96.     while (not turtle.place()) do
  97.         turtle.dig()
  98.     end
  99.     for num = 2, 16 do
  100.         turtle.select(num)
  101.         turtle.drop()
  102.     end
  103.     turtle.select(2)
  104.     left()
  105.     left()
  106.     if(turtle.getItemCount(1) == 0) then
  107.         error("Out of chests")
  108.     end
  109. end
  110.  
  111. -------------------------
  112.  
  113. local args = { ... }
  114.  
  115. arg1 = args[1]
  116. arg2 = args[2]
  117. arg3 = args[3]
  118.  
  119. side1 = tonumber(args[1])
  120. side2 = tonumber(args[2])
  121. depth = tonumber(args[3])
  122.  
  123. oddSide = false
  124.  
  125. if(side2 % 2 == 1) then
  126.     oddSide = true
  127. end
  128.  
  129. if(turtle.getItemCount(1) == 0) then
  130.     error("Place chests in slot 1 and try again")
  131. end
  132.  
  133. print(" ")
  134. print("Excavating these dimensions:")
  135. print("Out: " .. side1)
  136. print("Across: " .. side2)
  137. print("Down: " .. depth)
  138. print(" ")
  139.  
  140. layers = 0
  141. while(layers < depth) do
  142.     outer()
  143.     inner()
  144.     layers = layers + 1
  145.     if(layers < depth) then down() end
  146.     print((100*layers/depth) .. "% complete")
  147. end
  148.  
  149. print(" ")
  150. print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement