Advertisement
Henning_B

Untitled

Nov 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. local fuelSlot = 1
  2. local torchSlot = 2
  3. local firstItem,lastItem = 3,16
  4.  
  5. local currentHeigt = 1
  6. local currentLen = 1
  7. local currentWith = 2
  8.  
  9. local startHeight = 1
  10. local startLen = 1
  11. local startWith = 2
  12.  
  13. local tunnel length = 0
  14.  
  15. local fuelBarrel = nil
  16. local torchBarrel = nil
  17.  
  18.  
  19. local NORTH = 1
  20. local EAST = 2
  21. local SOUTH = 3
  22. local WEST = 4
  23. local currentFace = NORTH
  24.  
  25. function placeAll(all)
  26. local start = firstItem
  27. if(all) then
  28. start = 1
  29. end
  30. local i = firstItem
  31. while i <= lastItem do
  32. turtle.select(i)
  33. turtle.drop()
  34. if not turtle.getItemDetail() then
  35. i = i + 1
  36. else
  37. print("Chest is full, stopping")
  38. exit()
  39. end
  40. end
  41. end
  42.  
  43. function checkAndReset()
  44. local lookingAt = nil
  45. local itemData = nil
  46. lookingAt, itemData = turtle.inspect()
  47. if lookingAt then
  48. if string.match(itemData.name, "chest") then
  49. print("Found Chest")
  50. placeAll(true)
  51. else
  52. print("Missing loot Chest")
  53. return false
  54. end
  55. else
  56. print("Missing loot Chest")
  57. return false
  58. end
  59. turtle.turnLeft()
  60. turtle.forward()
  61. turtle.turnRight()
  62. lookingAt, itemData = turtle.inspect()
  63. if lookingAt then
  64. if string.match(itemData.name, "barrel") then
  65. print("found barrel")
  66. turtle.select(1)
  67. turtle.suck()
  68. item = turtle.getItemDetail()
  69. turtle.drop()
  70. if item then
  71. if string.match(item.name, "coal") then
  72. fuelBarrel = 1
  73. elseif string.match(item.name, "torch") then
  74. torchBarrel = 1
  75. else
  76. print("Missing coal or torch in barrel")
  77. return false
  78. end
  79. else
  80. print("Missing coal or torch in barrel")
  81. return false
  82. end
  83.  
  84. else
  85. print("Missing coal or torch barrel")
  86. return false
  87. end
  88. else
  89. print("Missing coal or torch barrel")
  90. return false
  91. end
  92.  
  93. turtle.up()
  94. lookingAt, itemData = turtle.inspect()
  95.  
  96. if lookingAt then
  97. if string.match(itemData.name, "barrel") then
  98. print("found barrel")
  99. turtle.select(1)
  100. turtle.suck()
  101. item = turtle.getItemDetail()
  102. turtle.drop()
  103. if item then
  104. if string.match(item.name, "coal") then
  105. fuelBarrel = 2
  106. elseif string.match(item.name, "torch") then
  107. torchBarrel = 2
  108. else
  109. print("Missing coal or torch in barrel")
  110. return false
  111. end
  112. else
  113. print("Missing coal or torch in barrel")
  114. return false
  115. end
  116.  
  117. else
  118. print("Missing coal or torch barrel")
  119. return false
  120. end
  121. else
  122. print("Missing coal or torch barrel")
  123. return false
  124. end
  125.  
  126. turtle.down()
  127. turtle.turnRight()
  128. turtle.forward()
  129. turtle.turnLeft()
  130. return true
  131.  
  132. end
  133.  
  134. function setDirection(direction)
  135. local turnAmount = currentFace - direction
  136. if turnAmount == 1 or turnAmount == -3 then
  137. turtle.turnRight()
  138. end
  139. if turnAmount == 2 or turnAmount == -2 then
  140. turtle.turnRight()
  141. turtle.turnRight()
  142. end
  143. if turnAmount == -1 or turnAmount == 3 then
  144. turtle.turnLeft()
  145. end
  146. end
  147.  
  148.  
  149. function Main()
  150. if checkAndReset() then
  151. print("All good")
  152. else
  153. print("sumting wong")
  154. end
  155. setDirection(NORTH)
  156. setDirection(EAST)
  157. setDirection(SOUTH)
  158. setDirection(WEST)
  159. setDirection(NORTH)
  160. setDirection(WEST)
  161. setDirection(SOUTH)
  162. setDirection(EAST)
  163. setDirection(NORTH)
  164.  
  165. end
  166.  
  167. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement