Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. xPos,zPos=0,0
  2. xDir,zDir=0,1
  3. movement=0
  4. xUnload=0
  5. xReFuel=0
  6.  
  7. function xPosition()
  8. if xDir == 0 then
  9. xPos = xPos + 1
  10. else
  11. xPos = xPos - 1
  12. end
  13. end
  14.  
  15. function zPosition()
  16. if zDir == 1 then
  17. zPos = zPos + 1
  18. else
  19. zPos = zPos - 1
  20. end
  21. end
  22.  
  23. function xForward()
  24. move()
  25. xPosition()
  26. end
  27.  
  28. function zForward()
  29. move()
  30. zPosition()
  31. end
  32.  
  33. function move()
  34. fuelUp()
  35. if not turtle.detect() then
  36. turtle.digUp()
  37. turtle.forward()
  38. else
  39. turtle.dig()
  40. turtle.digUp()
  41. turtle.attack()
  42. turtle.forward()
  43. end
  44. end
  45.  
  46. function unload()
  47. for i=2,16 do
  48. turtle.select(i)
  49. turtle.drop()
  50. end
  51.  
  52. xUnload = xUnload + 1
  53. print("unloaded " .. xUnload .. " times")
  54. turtle.rotateRight()
  55. turtle.rotateRight()
  56.  
  57. if xDir == 1 then
  58. xDir = 0
  59. end
  60. end
  61.  
  62. function fuelUp()
  63. if turtle.getFuelLevel() < 100 then
  64. turtle.select(1)
  65. turtle.refuel(1)
  66. xReFuel = xReFuel + 1
  67. print("refueled " .. xReFuel .. " times")
  68. end
  69. end
  70. -----------------------------------------------
  71. turtle.select(1)
  72. turtle.refuel(2)
  73. while true do
  74. turtle.turtleUp()
  75. for i=1,5 do
  76. xForward()
  77. end
  78.  
  79. ------------------------------
  80. function rotateRight()
  81. turtle.turnRight()
  82. if zDir == 1 then
  83. zDir = 0
  84. end
  85. end
  86. ------------
  87. rotateRight()
  88. --------------
  89. for i=1,movement do
  90. zForward()
  91. end
  92.  
  93. movement = movement + 1
  94.  
  95. function rotateLeft()
  96. turtle.turnLeft()
  97. if xDir == 1 then
  98. xDir = 0
  99. end
  100. end
  101.  
  102. rotateLeft()
  103.  
  104. for i=1,20 do
  105. turtle.digDown()
  106. xForward()
  107. end
  108.  
  109. function uTurn()
  110. print("turning arround")
  111. turtle.turnRight()
  112. zForward()
  113. turtle.turnRight()
  114. if xDir == 1 then
  115. xDir = 0
  116. else
  117. xDir = 1
  118. end
  119. print("successfully turned")
  120.  
  121. end
  122.  
  123. for i=1,20 do
  124. turtle.digDown()
  125. xForward()
  126. end
  127.  
  128. rotateRight()
  129.  
  130. for i=1,movement do
  131. zForward()
  132. end
  133.  
  134. rotateLeft()
  135.  
  136. for i=1,10 do
  137. xForward()
  138. end
  139.  
  140. turtle.turtleDown()
  141. unload()
  142.  
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement