Advertisement
pablaud

mineup V2

Mar 8th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs ~= 3 then
  3. print( "Uso: mineup <largo> <ancho> <prof.>" )
  4. return
  5. end
  6.  
  7. local largo = tonumber( tArgs[1] ) - 2
  8. local ancho = tonumber( tArgs[2] ) - 1
  9. local profundidad = tonumber( tArgs[3] ) - 1
  10. local pos = 1
  11. local count = 0
  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. up()
  29. turtle.up()
  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=0,largo do
  70. turtle.dig()
  71. forward()
  72. end
  73. end
  74.  
  75. function torcer()
  76. if count == ancho + 1 then
  77. count = 0
  78. else
  79. if pos == 1 then
  80. turtle.turnLeft()
  81. forward()
  82. turtle.turnLeft()
  83. pos = 0
  84. else
  85. turtle.turnRight()
  86. forward()
  87. turtle.turnRight()
  88. pos = 1
  89. end
  90. end
  91. end
  92.  
  93. function vuelta()
  94. turtle.turnLeft()
  95. turtle.turnLeft()
  96. end
  97.  
  98. function comprobarSlots()
  99. slots = 0
  100. for i=1,16 do
  101. if turtle.getItemCount(i) ~= 0 then
  102. slots = slots + 1
  103. end
  104. end
  105. end
  106.  
  107. function tirarItems()
  108. comprobarSlots()
  109. if slots == 16 then
  110. for i=1,16 do
  111. for k, v in pairs(turtle.getItemDetail(i)) do
  112. 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
  113. turtle.select(i)
  114. turtle.drop()
  115. end
  116. end
  117. end
  118. end
  119. end
  120.  
  121. ---------------------
  122.  
  123. start()
  124.  
  125. for i=0,profundidad do
  126. for i=0,ancho do
  127. tirarItems()
  128. avanzar()
  129. count = count + 1
  130. torcer()
  131. end
  132.  
  133. if pos == 1 then
  134. turtle.turnRight()
  135. for i=0,ancho - 1 do
  136. forward()
  137. end
  138. turtle.turnRight()
  139. for i=0,largo do
  140. forward()
  141. end
  142. vuelta()
  143. up()
  144. pos = 1
  145. else
  146. turtle.turnLeft()
  147. for i=0,ancho - 1 do
  148. forward()
  149. end
  150. turtle.turnLeft()
  151. up()
  152. pos = 1
  153. end
  154. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement