DrFair

Branch

Feb 4th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. Args = {...}
  2.  
  3. function digfor()
  4. while turtle.detect() do
  5. turtle.dig()
  6. os.sleep(0.5)
  7. end
  8. turtle.forward()
  9. end
  10.  
  11. function digup()
  12. while turtle.detectUp() do
  13. turtle.digUp()
  14. os.sleep(0.5)
  15. end
  16. end
  17.  
  18. function torch()
  19. turtle.turnRight()
  20. turtle.turnRight()
  21. turtle.select(2)
  22. turtle.place()
  23. turtle.turnRight()
  24. turtle.turnRight()
  25. end
  26.  
  27. function checkdown()
  28. if turtle.detectDown() == false then
  29. turtle.select(3)
  30. turtle.placeDown()
  31. end
  32. end
  33.  
  34. function checkfuel()
  35. fuel = turtle.getFuelLevel()
  36. if fuel <= 20 then
  37. turtle.select(1)
  38. turtle.refuel(1)
  39. end
  40. end
  41.  
  42. if #Args ~= 1 then
  43. print("Usage: branch <num>")
  44. n = 0
  45. else
  46. print("Branching "..Args[1].." blocks forward.")
  47. print("Fuel: slot 1, torch: slot 2, cobble: slot 3.")
  48. turtle.select(1)
  49. for i=1,Args[1] do
  50. checkfuel()
  51. n = n + 1
  52. digfor()
  53. digup()
  54. checkdown()
  55. if n == 7 then
  56. torch()
  57. n = 0
  58. end
  59. end
  60. turtle.up()
  61. for i=1,Args[1] do
  62. checkfuel()
  63. turtle.back()
  64. end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment