Advertisement
onlyjb

hole

Jul 26th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. local args = { ... }
  2. if #args ~= 3 then
  3. term.setCursorPos(1,1)
  4. term.clear()
  5. print("hole Hoehe|Breite|Tiefe")
  6. error()
  7. end
  8.  
  9. x = args[1]+0
  10. xDone = 1
  11. y = args[2]+0
  12. yDone = 1
  13. z = args[3]+0
  14. zDone = 1
  15. energy = x*y*z
  16. done = 0
  17.  
  18. item = 1
  19. direction = 0
  20.  
  21. if (x < 2) or (y < 2) or (z < 2) then
  22. print("Werte kleiner als 2 werden nicht aktzeptiert!")
  23. error()
  24. end
  25.  
  26.  
  27. end
  28.  
  29. function checkFuelToWork()
  30. while item <= 16 do
  31. turtle.select(item)
  32. turtle.refuel()
  33. item = item+1
  34. end
  35. turtle.select(1)
  36. curFuel = turtle.getFuelLevel()
  37. coal = energy/80
  38. if energy > curFuel then
  39. term.clear()
  40. term.setCursorPos(1,1)
  41. print("Es wird "..energy.." Energie benoetigt.")
  42. print("Bitte mindestens "..coal.." Kohle nachlegen!")
  43. error()
  44. end
  45. end
  46.  
  47. function mainLoop()
  48. while zDone <= z do
  49. while yDone <= y do
  50. while xDone < x do
  51. digFor()
  52. xDone = xDone+1
  53. runGUI()
  54. end
  55. turnIt()
  56. yDone = yDone+1
  57. xDone = 1
  58. end
  59. goDown()
  60. zDone = zDone+1
  61. yDone = 1
  62. end
  63. end
  64.  
  65. function digFor()
  66. turtle.dig()
  67. while not turtle.forward() do
  68. turtle.attack()
  69. sleep(0.5)
  70. end
  71. end
  72.  
  73. function goDown()
  74. if x ~= xDone then
  75. turtle.digDown()
  76. while not turtle.down() do
  77. turtle.attackDown()
  78. end
  79. else
  80. comeBack()
  81. end
  82. end
  83.  
  84. function turnIt()
  85. if (y == 1) or (yDone == y) then
  86. turtle.turnRight()
  87. turtle.turnRight()
  88. else
  89. if direction == 0 then
  90. turtle.turnRight()
  91. digFor()
  92. turtle.turnRight()
  93. direction = 1
  94. else
  95. turtle.turnLeft()
  96. digFor()
  97. turtle.turnLeft()
  98. direction = 0
  99. end
  100. end
  101. end
  102.  
  103. function runGUI()
  104. term.clear()
  105. term.setCursorPos(1,1)
  106. done = done + 1
  107. percentage = done/energy*100
  108. print(percentage.."% abgeschlossen...")
  109. end
  110.  
  111. function comeBack()
  112. xUp=1
  113. while xUp < x do
  114. turtle.up()
  115. xUp = xUp + 1
  116. end
  117. end
  118.  
  119. checkFuelToWork()
  120. mainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement