Advertisement
pablaud

down perfect

Mar 4th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs ~= 3 then
  3. print( "Uso: down <largo> <ancho> <profundidad>" )
  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] )
  10. local pos = 1
  11. local count = 0
  12.  
  13. function checkFuel()
  14. if turtle.getFuelLevel() < 20 then
  15. turtle.select(1)
  16. turtle.refuel(1)
  17. print("Refuelling")
  18. else
  19. print("No fuel necessary")
  20. end
  21. end
  22.  
  23. function start()
  24. turtle.digDown()
  25. turtle.down()
  26. end
  27.  
  28. function forward()
  29. while turtle.forward() == false do
  30. turtle.dig()
  31. turtle.attack()
  32. sleep(0.25)
  33. end
  34. end
  35.  
  36. function back()
  37. while turtle.back() == false do
  38. turtle.turnLeft()
  39. turtle.turnLeft()
  40. turtle.dig()
  41. turtle.turnLeft()
  42. turtle.turnLeft()
  43. sleep(0.25)
  44. end
  45. end
  46.  
  47. function up()
  48. while turtle.up() == false do
  49. turtle.digUp()
  50. turtle.attack()
  51. sleep(0.25)
  52. end
  53. end
  54.  
  55. function down()
  56. while turtle.down() == false do
  57. turtle.digDown()
  58. turtle.attack()
  59. sleep(0.25)
  60. end
  61. end
  62.  
  63. function avanzar()
  64. for i=0,largo do
  65. turtle.dig()
  66. forward()
  67. end
  68. end
  69.  
  70. function torcer()
  71. if count == ancho + 1 then
  72. count = 0
  73. else
  74. if pos == 1 then
  75. turtle.turnLeft()
  76. forward()
  77. turtle.turnLeft()
  78. pos = 0
  79. else
  80. turtle.turnRight()
  81. forward()
  82. turtle.turnRight()
  83. pos = 1
  84. end
  85. end
  86. end
  87.  
  88. function vuelta()
  89. turtle.turnLeft()
  90. turtle.turnLeft()
  91. end
  92.  
  93. start()
  94.  
  95. for i=0,ancho do
  96. avanzar()
  97. count = count + 1
  98. torcer()
  99. end
  100.  
  101. if pos == 1 then
  102. turtle.turnRight()
  103. for i=0,ancho - 1 do
  104. forward()
  105. end
  106. turtle.turnRight()
  107. for i=0,largo do
  108. forward()
  109. end
  110. vuelta()
  111. else
  112. turtle.turnLeft()
  113. for i=0,ancho - 1 do
  114. forward()
  115. end
  116. turtle.turnLeft()
  117.  
  118. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement