Advertisement
GladdeSnaak

Untitled

Jul 9th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. cords = {}
  2. cords["x"] = 0
  3. cords["z"] = 0
  4. itemInfo = {}
  5.  
  6. function distance()
  7. return cords["x"] + cords["z"]
  8. end
  9.  
  10. function checkFuel()
  11. if turtle.getFuelLevel() < cords["x"] then
  12. for i = 1,16 do
  13. itemInfo = turtle.getItemDetail(i)
  14. if itemInfo["name"] == "minecraft:coal" then
  15. turtle.select(i)
  16. turtle.refuel(itemInfo["count"])
  17. end
  18. end
  19. end
  20. end
  21.  
  22. function forward(blocksF)
  23. turtle.digDown()
  24. for repeats = 1,blocksF do
  25. checkFuel()
  26. turtle.dig()
  27. turtle.forward()
  28. turtle.digDown()
  29. turtle.digUp()
  30. logCordX(1)
  31. end
  32. end
  33.  
  34. function back(blocksB)
  35. turtle.turnLeft()
  36. turtle.turnLeft()
  37. for repeats = 1,blocksB do
  38. turtle.dig()
  39. turtle.forward()
  40. if turtle.inspectUp() == "minecraft:chest" then
  41. print("Chest above")
  42. else
  43. turtle.digUp()
  44. end
  45. turtle.digDown()
  46. logCordX(-1)
  47. end
  48. turtle.turnLeft()
  49. turtle.turnLeft()
  50. end
  51.  
  52. function logCordX(changeX)
  53. cords["x"] = cords["x"] + changeX
  54. end
  55.  
  56. function right()
  57. turtle.turnRight()
  58. turtle.dig()
  59. turtle.forward()
  60. turtle.digUp()
  61. turtle.digDown()
  62. turtle.turnLeft()
  63. logCordZ(-1)
  64. end
  65.  
  66. function left()
  67. turtle.turnLeft()
  68. turtle.dig()
  69. turtle.forward()
  70. turtle.digUp()
  71. turtle.digDown()
  72. turtle.turnRight()
  73. logCordZ(1)
  74. end
  75.  
  76. function logCordZ(changeZ)
  77. cords["z"] = cords["z"] + changeZ
  78. end
  79.  
  80. function sRight(blocksR)
  81. turtle.turnRight()
  82. for repeats = 1,blocksR do
  83. turtle.dig()
  84. turtle.forward()
  85. if turtle.inspectUp() == "minecraft:chest" then
  86. print("Chest above")
  87. else
  88. turtle.digUp()
  89. end
  90. turtle.digDown()
  91. logCordZ(-1)
  92. end
  93. turtle.turnLeft()
  94. end
  95.  
  96. function sLeft(blocksL)
  97. turtle.turnLeft()
  98. for repeats = 1,blocksL do
  99. turtle.dig()
  100. turtle.forward()
  101. if turtle.inspectUp() == "minecraft:chest" then
  102. print("Chest above")
  103. else
  104. turtle.digUp()
  105. end
  106. turtle.digDown()
  107. logCordZ(1)
  108. end
  109. turtle.turnRight()
  110. end
  111.  
  112. function goHome()
  113. if cords["x"] > 0 then
  114. back(cords["x"])
  115. elseif cords["x"] < 0 then
  116. Travelx = -1 * cords["x"]
  117. forward(Travelx)
  118. end
  119. if cords["z"] > 0 then
  120. sRight(cords["z"])
  121. elseif cords["z"] < 0 then
  122. Travelz = -1 * cords["z"]
  123. sLeft(Travelz)
  124. end
  125. for i = 1,16 do
  126. turtle.select(i)
  127. turtle.dropUp()
  128. end
  129. end
  130.  
  131.  
  132. function checkInv(row)
  133. for i = row,16 do
  134. turtle.select(i)
  135. if turtle.getItemDetail ~= nil then
  136. status = true
  137. end
  138. end
  139. if status then
  140. goHome()
  141. end
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement