drexplosionpd

stripMine_new

Jun 19th, 2022 (edited)
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. is_ender_chest = false
  2. torch_slot = 1
  3. torch_distance = 12
  4. chest_slot = 2
  5. turn_distance = 32
  6. -- 1 is left, 2 is right
  7. turn_dir = 1
  8.  
  9.  
  10.  
  11. local function forward()
  12. while turtle.dig() do end
  13. turtle.forward()
  14. while turtle.digUp() do end
  15. end
  16.  
  17. local function scan()
  18. local bool, data = turtle.inspect()
  19. if bool then
  20. if string.find(data.name,"diamond") then
  21. print("FOUND "..data.name.." WAITING FOR INPUT")
  22. read()
  23. end
  24. end
  25. end
  26.  
  27. local function turn(movecount)
  28. if movecount % turn_distance == 0 then
  29. if 1 % turn_dir == 0 then
  30. turn_dir = 2
  31. turtle.turnLeft()
  32. forward()
  33. forward()
  34. forward()
  35. turtle.turnLeft()
  36. else
  37. turn_dir = 1
  38. turtle.turnRight()
  39. forward()
  40. forward()
  41. forward()
  42. turtle.turnRight()
  43. end
  44. end
  45. end
  46.  
  47. local function torch(movecount)
  48. if movecount % torch_distance == 0 then
  49. turtle.turnLeft()
  50. turtle.turnLeft()
  51. while turtle.dig() do end
  52. turtle.select(torch_slot)
  53. turtle.place()
  54. turtle.turnLeft()
  55. turtle.turnLeft()
  56. end
  57. end
  58.  
  59. local function checkSlots()
  60. hasItemsFlag = true
  61. repeat
  62. if turtle.getItemCount(torch_slot) == 0 then
  63. hasItemsFlag = false
  64. print("missing torches in slot "..torch_slot)
  65. elseif turtle.getItemCount(chest_slot) == 0 then
  66. hasItemsFlag = false
  67. print("missing chests in slot "..chest_slot)
  68. elseif turtle.getFuelLevel() < 1000 then
  69. hasItemsFlag = false
  70. print("turtle fuel is below acceptable levels ("..turtle.getFuelLevel()..")")
  71. else
  72. hasItemsFlag = true
  73. end
  74. sleep(1)
  75. until hasItemsFlag
  76. end
  77.  
  78. local function dumpItems()
  79. turtle.digDown()
  80. turtle.select(chest_slot)
  81. if turtle.placeDown() then
  82. for i = 3, 16 do
  83. turtle.select(i)
  84. turtle.dropDown()
  85. end
  86. end
  87.  
  88. if is_ender_chest then
  89. turtle.select(chest_slot)
  90. turtle.digDown()
  91. end
  92. end
  93.  
  94. local function isFull()
  95. fullFlag = true
  96. for i = 3, 16 do
  97. if turtle.getItemCount(i) == 0 then
  98. fullFlag = false
  99. end
  100. end
  101.  
  102. if fullFlag then
  103. dumpItems()
  104. end
  105. end
  106.  
  107. local function main()
  108. checkSlots()
  109. moves = 0
  110. while true do
  111. isFull()
  112. scan()
  113. torch(moves)
  114. forward()
  115. moves = moves + 1
  116. turn(moves)
  117. end
  118. end
  119.  
  120. main()
Add Comment
Please, Sign In to add comment