hunter3216

aquamarinePlacerAdvanced.lua

Mar 18th, 2023 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. -- shell.run("rm loadAPIs.lua") shell.run("pastebin get 6x0B3PVu loadAPIs.lua") shell.run("loadAPIs.lua") shell.run("rm aquamarinePlacerAdvanced.lua") shell.run("pastebin get C0dTipWs aquamarinePlacerAdvanced.lua") shell.run("aquamarinePlacerAdvanced.lua")
  2.  
  3. -- Configured for 4x2
  4. robot.init()
  5. robot.initGPS()
  6. robot.initAutomata()
  7. robot.goHome()
  8. robot.setFuelConsumptionRate(2)
  9.  
  10. function getItemSlot()
  11. turtle.select(1)
  12. while turtle.getItemCount() == 0 and turtle.getSelectedSlot() ~= 16 do
  13. turtle.select(turtle.getSelectedSlot() + 1)
  14. end
  15. end
  16.  
  17. function getCharcoal()
  18. robot.select(16)
  19. robot.suckDown(64 - robot.getItemCount())
  20. end
  21.  
  22. function getAquamarine()
  23. for i = 1, 15 do
  24. robot.select(i)
  25. robot.suckDown(64 - robot.getItemCount())
  26.  
  27. local item = robot.getItemDetail()
  28. if item ~= nil and item.name == "mekanism:block_charcoal" then
  29. robot.dropDown()
  30. return false
  31. end
  32.  
  33. end
  34. end
  35.  
  36. function aquaCheckAndPlace()
  37. well = peripheral.wrap("front")
  38. if turtle.getFuelLevel() < 80 then
  39. turtle.select(16)
  40. turtle.refuel()
  41. end
  42. wellCur = well.tanks()
  43. wellItems = well.list()
  44.  
  45. -- Check to see that there is no aquamarine and that the tank contains less than 2000mb
  46. if (wellItems[1] == nil) and ((wellCur[1] == nil or wellCur[1].amount < 2000)) then
  47. getItemSlot()
  48. robot.useOnBlock(true)
  49. end
  50. end
  51.  
  52. function notEmpty()
  53. local itemNum = 0
  54. for i = 1, 15 do
  55. robot.select(i)
  56. itemNum = itemNum + robot.getItemCount()
  57. end
  58. if itemNum == 0 then
  59. print("Out of Aquamarine!")
  60. return false
  61. else
  62. return true
  63. end
  64. end
  65.  
  66. while true do
  67. getCharcoal()
  68. getAquamarine()
  69. getItemSlot()
  70. if notEmpty() then
  71. aquaCheckAndPlace()
  72. robot.right()
  73. aquaCheckAndPlace()
  74. robot.right()
  75. aquaCheckAndPlace()
  76. robot.right()
  77. aquaCheckAndPlace()
  78. robot.right()
  79. robot.forward(3)
  80. robot.turnLeft()
  81. robot.forward()
  82. robot.turnLeft()
  83. aquaCheckAndPlace()
  84. robot.right()
  85. aquaCheckAndPlace()
  86. robot.right()
  87. aquaCheckAndPlace()
  88. robot.right()
  89. aquaCheckAndPlace()
  90. robot.right()
  91. robot.forward(3)
  92. robot.turnLeft()
  93. robot.forward()
  94. robot.turnLeft()
  95.  
  96. os.sleep(60)
  97. end
  98. end
Advertisement
Add Comment
Please, Sign In to add comment