Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. d = tonumber(read())
  2. l = tonumber(read())
  3. h = tonumber(read())
  4. turnRight = true
  5. fuelNeeded = d * l * h + d + l + h - 1
  6. fuelLevel = turtle.getFuelLevel()
  7. y = 0
  8. x = 0
  9. z = 0
  10. function clearInventory()
  11. turtle.turnRight()
  12. for i = 1, 16 do
  13. turtle.drop(64)
  14. end
  15. turtle.turnLeft()
  16. end
  17. function turnArround()
  18. turtle.turnRight()
  19. turtle.turnRight()
  20. end
  21. function returnToChest()
  22. for i = 1, y do
  23. turtle.up()
  24. end
  25. if (z > 0) then
  26. turnRight = not turnRight
  27. turn()
  28. for i = 1, z do
  29. turtle.forward()
  30. end
  31. turnRight = not turnRight
  32. turn()
  33. end
  34. if (turnRight) then turnArround() end
  35. for i = 1, x do
  36. turtle.forward()
  37. end
  38. turnArround()
  39. end
  40. function digAndMove(dir)
  41. array = {}
  42. skip = false
  43. detecting = false
  44. if (dir == 1) then detecting = turtle.detect() else detecting = turtle.detectDown() end
  45. while (detecting) do
  46. for i = 1, 16 do
  47. if (turtle.getItemCount(i) == not null) then
  48. a[i] = turtle.getItemCount(i)
  49. else
  50. skip = true
  51. end
  52. end
  53. if (dir == 1) then
  54. turtle.dig()
  55. elseif (dir == 2) then
  56. turtle.digUp()
  57. end
  58. turtle.suck()
  59. if (not skip) then
  60. for i = 1, 16 do
  61. if (turtle.getItemCount(i) == not a[i]) then break end
  62. if (i == 16) then
  63. returnToChest()
  64. clearInventory()
  65. for i = 1, y do
  66. turtle.down()
  67. end
  68. for i = 1, x do
  69. turtle.forward()
  70. end
  71. if (z > 0) then
  72. turtle.turnRight()
  73. for i = 1, z do
  74. turtle.forward()
  75. end
  76. end
  77. if (not turnRight) then turnArround() end
  78. break;
  79. end
  80. end
  81. end
  82. if (dir == 1) then detecting = turtle.detect() else detecting = turtle.detectDown() end
  83. end
  84. if (dir == 1) then
  85. turtle.forward()
  86. elseif (dir == 2) then
  87. turtle.down()
  88. end
  89.  
  90. end
  91. function turn ()
  92. if (turnRight) then turtle.turnRight() else turtle.turnLeft() end
  93. end
  94. clearInventory()
  95. -- if (fuelLevel < fuelNeeded) then turtle.suck((fuelNeeded - fuelLevel) / 80) end
  96. digAndMove(1)
  97. x = x + 1
  98. for i = 1, h do
  99. for j = 1, l do
  100. if (j > 1) then
  101. turn()
  102. digAndMove(1)
  103. if ((y + 2) % 2 == 0) then z = z + 1 else z = z - 1 end
  104. turn()
  105. turnRight = not turnRight
  106. end
  107. for k = 2, d do
  108. digAndMove(1)
  109. if (turnRight) then x = x + 1 else x = x - 1 end
  110. end
  111. end
  112. if (i < h) then
  113. digAndMove(2)
  114. y = y + 1
  115. turnArround()
  116. end
  117. end
  118. returnToChest()
  119. clearInventory()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement