Shiru21

AutomaticHydroangeas

Aug 19th, 2021 (edited)
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.31 KB | None | 0 0
  1. -- Left  = "Blue Shimmering Mushroom" Storage
  2. -- Right = "Cyan Shimmering Mushroom" Storage
  3. -- Back  = "Wheat Seeds" Storage
  4.  
  5. blueShroom = "botania:blue_mushroom"
  6. cyanShroom = "botania:cyan_mushroom"
  7. seeds = "minecraft:wheat_seeds"
  8.  
  9. function pickLeft()
  10.     turtle.turnLeft()
  11.     turtle.suck(2)
  12.     while(not hasItem(blueShroom, 2)) do
  13.         os.sleep(120)
  14.         if(hasItem(blueShroom, 1)) then
  15.             turtle.suck(1)
  16.         else
  17.             turtle.suck(2)
  18.         end
  19.     end
  20.     turtle.turnRight()
  21. end
  22.  
  23. function pickRight()
  24.     turtle.turnRight()
  25.     turtle.suck(2)
  26.     while(not hasItem(cyanShroom, 2)) do
  27.         os.sleep(120)
  28.         if(hasItem(cyanShroom, 1)) then
  29.             turtle.suck(1)
  30.         else
  31.             turtle.suck(2)
  32.         end
  33.     end
  34.     turtle.turnLeft()
  35. end
  36.  
  37. function pickBack()
  38.     turtle.turnRight()
  39.     turtle.turnRight()
  40.     turtle.suck(1)
  41.     while(not hasItem(seeds, 1)) do
  42.         os.sleep(120)
  43.         turtle.suck(1)
  44.     end
  45.     turtle.turnLeft()
  46.     turtle.turnLeft()
  47. end
  48.  
  49. function hasItem(itemID, itemCount)
  50.     for i = 1, 16 do
  51.     turtle.select(i)
  52.         if turtle.getItemCount(turtle.getSelectedSlot()) ~= 0 then
  53.             detailTable = turtle.getItemDetail(turtle.getSelectedSlot())
  54.             currentID = detailTable.name
  55.             currentCount = detailTable.count
  56.             if currentID == itemID and currentCount == itemCount then
  57.                 print("found item : ", currentID)
  58.                 return true
  59.             end
  60.         end
  61.     end
  62.     return false
  63. end
  64.  
  65. function selectSpecItem(itemName)
  66.     for i = 1, 16 do
  67.     turtle.select(i)
  68.         if turtle.getItemCount(turtle.getSelectedSlot()) ~= 0 then
  69.             detailTable = turtle.getItemDetail(turtle.getSelectedSlot())
  70.             currentName = detailTable.name
  71.             if currentName == itemName then
  72.                 return true
  73.             end
  74.         end
  75.     end
  76. end
  77.  
  78. --INIT
  79. while(turtle.detect()) do
  80.     turtle.turnRight()
  81. end
  82.  
  83.     --Drop remaining cyan shrooms
  84. turtle.turnRight()
  85. selectSpecItem(cyanShroom)
  86. turtle.drop()
  87.  
  88.     --Drop remaining seeds
  89. turtle.turnRight()
  90. selectSpecItem(seeds)
  91. turtle.drop()
  92.  
  93.     --Drop remaining blue shrooms
  94. turtle.turnRight()
  95. selectSpecItem(blueShroom)
  96. turtle.drop()
  97.  
  98. while(turtle.detect()) do
  99.     turtle.turnRight()
  100. end
  101.  
  102. --MAIN LOOP
  103. while(true) do
  104.     pickLeft()
  105.     pickRight()
  106.     pickBack()
  107.     selectSpecItem(blueShroom)
  108.     turtle.drop(2)
  109.     selectSpecItem(cyanShroom)
  110.     turtle.drop(2)
  111.     selectSpecItem(seeds)
  112.     turtle.drop(1)
  113.     os.sleep(5)
  114. end
Add Comment
Please, Sign In to add comment