Advertisement
Guest User

turtletest

a guest
Jun 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. bool inPit = false
  2. int loops = 1
  3.  
  4. local function forward(count)
  5. if count == nil then count = 1 end
  6. for i = 0, count do
  7. turtle.forward()
  8. end
  9. end
  10.  
  11. local function up(count)
  12. if count == nil then count = 1 end
  13. for i = 0, count do
  14. turtle.up()
  15. end
  16. end
  17.  
  18. local function down(count)
  19. if count == nil then count = 1 end
  20. for i = 0, count do
  21. turtle.down()
  22. end
  23. end
  24.  
  25. local function turnLeft(count)
  26. if count == nil then count = 1 end
  27. for i = 0, count do
  28. turtle.turnLeft()
  29. end
  30. end
  31.  
  32. local function turnRight(count)
  33. if count == nil then count = 1 end
  34. for i = 0, count do
  35. turtle.turnRight()
  36. end
  37. end
  38.  
  39. local function enterPit()
  40. turtle.forward(3)
  41. down()
  42. inPit = true
  43. return true
  44. end
  45.  
  46. local function exitPit()
  47. turnLeft(2)
  48. up()
  49. forward(3)
  50. turnLeft(2)
  51. inPit = false
  52. return true
  53. end
  54.  
  55. local function deposit()
  56. turnLeft()
  57. turtle.up()
  58. forward(2)
  59. for i = 3,16 do
  60. turtle.select(i)
  61. turtle.dropDown()
  62. end
  63. turtle.select(1)
  64. turnRight(2)
  65. forward(2)
  66. turtle.down()
  67. turnLeft()
  68. return true
  69. end
  70.  
  71. local function refuel()
  72. if inPit then
  73. exitPit()
  74. end
  75. deposit()
  76. turnRight()
  77. turtle.select(2)
  78. turtle.place()
  79. turtle.select(1)
  80. turnLeft
  81. forward(2)
  82. down()
  83. turtle.digDown()
  84. os.sleep(3)
  85. turtle.placeDown()
  86. turtle.refuel()
  87. exitPit()
  88. forward()
  89. turnRight()
  90. turtle.dig()
  91. turtle.select(3)
  92. turtle.transferTo(2)
  93. return true
  94. end
  95.  
  96. local function digLoopOnce()
  97. function turnCorner()
  98. forward()
  99. turnRight()
  100. forward()
  101. end
  102. turtle.digDown()
  103. turnLeft()
  104. turnCorner()
  105. turtle.digDown()
  106. turnCorner()
  107. turtle.digDown()
  108. turnCorner()
  109. turtle.digDown()
  110. turnCorner()
  111. turnRight()
  112. end
  113.  
  114. local function start()
  115. enterPit()
  116. for i = 0,loops do
  117. if turtle.getFuelLevel() < 1000 then
  118. exitPit()
  119. refuel()
  120. enterPit()
  121. end
  122.  
  123. digLoopOnce()
  124. if getItemCount(16) > 0 then
  125. deposit()
  126. end
  127. end
  128. exitPit()
  129. end
  130.  
  131. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement