Godleydemon

Untitled

Jun 9th, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. -- improved version of clearCube by BlockPortal
  2. -- http://turtlescripts.com/project/gjdh1o-clearCube
  3. -- improved by truhgoj
  4. -- Clears a x by y by z area
  5.  
  6. local FUEL_SLOT = 1
  7. local FUEL_ENDERCHEST = 0
  8. local STORAGE_ENDERCHEST = 0
  9.  
  10. --should the turtle dig up
  11. local shouldDigUp = true
  12.  
  13. -- @return true if any slot is empty
  14. function slotsEmpty()
  15. for i=1, 16 do
  16. if turtle.getItemCount(i) < 1 then
  17. return true
  18. end
  19. end
  20. return false
  21. end
  22.  
  23. function clear()
  24. term.clear()
  25. term.setCursorPos(1,1)
  26. end
  27.  
  28. function up()
  29. while not turtle.up() do
  30. turtle.digUp()
  31. end
  32. end
  33.  
  34. function down()
  35. while not turtle.down() do
  36. turtle.digDown()
  37. end
  38. end
  39.  
  40. function forward()
  41. while not turtle.forward() do
  42. turtle.dig()
  43. end
  44. end
  45.  
  46. function back()
  47. while not turtle.back() do
  48. turtle.turnLeft()
  49. turtle.turnLeft()
  50. turtle.dig()
  51. turtle.turnLeft()
  52. turtle.turnLeft()
  53. end
  54. end
  55.  
  56. function clearLine()
  57. for i = 1, depth do
  58.  
  59. turtle.dig()
  60. forward()
  61. turtle.digUp()
  62. turtle.digDown()
  63. end
  64.  
  65. for i = 1, depth do
  66. back()
  67. end
  68. end
  69.  
  70. function clearWall()
  71. local i=1
  72. while i <= height do
  73. end
  74.  
  75. if shouldDigUp then turtle.digUp() else turtle.digDown() end
  76.  
  77. if i < height and i > 1 then
  78. if shouldDigUp then up() else down() end
  79. if shouldDigUp then turtle.digUp() else turtle.digDown() end
  80. i = i + 1
  81. end
  82.  
  83. if i < height then
  84. if shouldDigUp then up() else down() end
  85. if shouldDigUp then turtle.digUp() else turtle.digDown() end
  86. i = i + 1
  87. end
  88.  
  89. clearLine()
  90. if shouldDigUp then up() else down() end
  91. i = i +1
  92. end
  93.  
  94. for i = 1, height do
  95. if shouldDigUp then down() else up() end
  96. end
  97.  
  98. function clearCube()
  99. for i = 1, width do
  100. clearWall()
  101. turtle.turnRight()
  102. forward()
  103. turtle.turnLeft()
  104. end
  105.  
  106. turtle.turnLeft()
  107.  
  108. for i = 1, width+1 do
  109. forward()
  110. end
  111.  
  112. turtle.turnRight()
  113. end
  114.  
  115. tArgs = {...}
  116.  
  117. --print(tArgs[1] .. " " .. type(tArgs[1]) .. " " .. tArgs[2] .. " " .. type(tArgs[2]) .. " " .. tArgs[3] .. " " .. type(tArgs[3]))
  118.  
  119. if type(tArgs[1]) == "string" and type(tArgs[2]) == "string" and type(tArgs[3]) == "string" and tonumber(tArgs[1]) > 0 and tonumber(tArgs[2]) > 0 and tonumber(tArgs[3]) ~= 0 then
  120. depth = tonumber(tArgs[1])
  121. width = tonumber(tArgs[2])
  122. height = tonumber(tArgs[3])
  123. else
  124. term.write("Insert depth: ")
  125. depth = tonumber(read())
  126. print(" ")
  127.  
  128. term.write("Insert width: ")
  129. width = tonumber(read())
  130. print(" ")
  131.  
  132. term.write("Insert height: ")
  133. height = tonumber(read())
  134. print(" ")
  135. end
  136.  
  137. refuel()
  138.  
  139. if height < 0 then
  140. height = height * (-1)
  141. shouldDigUp = false
  142. end
  143.  
  144. height = height -1
  145. clearCube()
Advertisement
Add Comment
Please, Sign In to add comment