Creadth

Untitled

Nov 19th, 2023 (edited)
1,123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. function redstonePulse(side)
  2.     local status = redstone.getOutput(side);
  3.     redstone.setOutput(side, not status);
  4.     os.sleep(0.05);
  5.     redstone.setOutput(side, status);
  6. end
  7.  
  8. local readyChestSide = "top";
  9. local beltInvertorSide = "back";
  10. local seedInputSide = "bottom";
  11.  
  12. local grownCrystalName = "appliedenergistics2:purified_certus_quartz_crystal";
  13.  
  14. --local monitor = peripheral.wrap('right');
  15. local belt = peripheral.wrap('right');
  16. local items
  17. --monitor.setCursorPos(1,1);
  18. --monitor.setTextScale(0.5);
  19. redstone.setOutput(beltInvertorSide, false)
  20. --monitor.write('Detecting...');
  21. redstone.setOutput(readyChestSide, true);
  22. redstone.setOutput(seedInputSide, true);
  23. local ticksWithoutItem = 0;
  24. print('Detecting')
  25. while true do
  26.     items = belt.list();
  27.     if #items > 0 then
  28.         ticksWithoutItem = 0;
  29.         --monitor.clear();
  30.         local item = belt.getItemDetail(1);
  31.         if (item.name ~= grownCrystalName) then
  32.             print("Crystal is not ready, another iteration");
  33.             redstone.setOutput(beltInvertorSide, true);
  34.             os.sleep(4);
  35.             redstone.setOutput(beltInvertorSide, false)
  36.         else
  37.             print("Crystal is ready!");
  38.             redstonePulse(readyChestSide);
  39.             redstonePulse(seedInputSide);
  40.         end
  41.     else
  42.         ticksWithoutItem=ticksWithoutItem+1;
  43.         if (ticksWithoutItem > 600) then
  44.             print("No items detected on the belt for 600 ticks, requesting another item");
  45.             redstonePulse(seedInputSide);
  46.             ticksWithoutItem = 0;
  47.         end
  48.     end
  49.     os.sleep(0.1);
  50. end
Advertisement
Add Comment
Please, Sign In to add comment