Advertisement
pablaud

mine

Mar 8th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs ~= 3 then
  3. print( "Uso: mine <alto> <ancho> <prof.>" )
  4. return
  5. end
  6.  
  7. local alto = tonumber( tArgs[1] ) - 1
  8. local ancho = tonumber( tArgs[2] ) - 1
  9. local profundidad = tonumber( tArgs[3] ) - 1
  10. local count = 0
  11. local pos = 1
  12. local slots = 0
  13.  
  14. function checkFuel()
  15. print("Combustible actual:" .. turtle.getFuelLevel() .. " ")
  16. if turtle.getFuelLevel() < 20 then
  17. turtle.select(1)
  18. turtle.refuel(1)
  19. print("Repostando...")
  20.  
  21. else
  22. print("tuturu")
  23. end
  24. end
  25.  
  26. function start()
  27. checkFuel()
  28. forward()
  29. turtle.turnLeft()
  30. end
  31.  
  32. function forward()
  33. checkFuel()
  34. while turtle.forward() == false do
  35. turtle.dig()
  36. turtle.attack()
  37. sleep(0.25)
  38. end
  39. end
  40.  
  41. function back()
  42. while turtle.back() == false do
  43. turtle.turnLeft()
  44. turtle.turnLeft()
  45. turtle.dig()
  46. turtle.turnLeft()
  47. turtle.turnLeft()
  48. sleep(0.25)
  49. end
  50. end
  51.  
  52. function up()
  53. while turtle.up() == false do
  54. turtle.digUp()
  55. turtle.attack()
  56. sleep(0.25)
  57. end
  58. end
  59.  
  60. function down()
  61. while turtle.down() == false do
  62. turtle.digDown()
  63. turtle.attack()
  64. sleep(0.25)
  65. end
  66. end
  67.  
  68. function avanzar()
  69. for i=1,ancho do
  70. turtle.dig()
  71. forward()
  72. end
  73. end
  74.  
  75. function vuelta()
  76. turtle.turnLeft()
  77. turtle.turnLeft()
  78. end
  79.  
  80. function comprobarSlots()
  81. slots = 0
  82. for i=1,16 do
  83. if turtle.getItemCount(i) ~= 0 then
  84. slots = slots + 1
  85. end
  86. end
  87. end
  88.  
  89. function tirarItems()
  90. comprobarSlots()
  91. if slots == 16 then
  92. for i=1,16 do
  93. for k, v in pairs(turtle.getItemDetail(i)) do
  94. if k == "name" and v == "minecraft:cobblestone" or v == "minecraft:dirt" or v == "BigReactors:YelloriteOre" or v == "ThermalFoundation:Ore" or v == "minecraft:redstone" or v == "minecraft:dye" or v == "Forestry:apatite" or v == "minecraft:gravel" or v == "chisel:limestone" or v == "chisel:diorite" or v == "chisel:granite" then
  95. turtle.select(i)
  96. turtle.drop()
  97. end
  98. end
  99. end
  100. end
  101. end
  102.  
  103. ---------------------
  104.  
  105. start()
  106.  
  107. for i=0,profundidad do
  108. for i=0,alto do
  109. tirarItems()
  110. avanzar()
  111. if pos == 1 then
  112. pos = 0
  113. else
  114. pos = 1
  115. end
  116. vuelta()
  117. count = count + 1
  118. if count == alto + 1 then
  119. count = 0
  120. else
  121. up()
  122. end
  123.  
  124. end
  125. if pos == 0 then
  126. for i=0,ancho - 1 do
  127. forward()
  128. end
  129. vuelta()
  130. for i=1,alto do
  131. down()
  132. end
  133. turtle.turnRight()
  134. forward()
  135. turtle.turnLeft()
  136. pos = 1
  137. else
  138. for i=0,alto - 1 do
  139. down()
  140. end
  141. turtle.turnRight()
  142. forward()
  143. turtle.turnLeft()
  144. pos = 1
  145. end
  146. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement