Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function redstonePulse(side)
- local status = redstone.getOutput(side);
- redstone.setOutput(side, not status);
- os.sleep(0.05);
- redstone.setOutput(side, status);
- end
- local readyChestSide = "top";
- local beltInvertorSide = "back";
- local seedInputSide = "bottom";
- local grownCrystalName = "appliedenergistics2:purified_certus_quartz_crystal";
- --local monitor = peripheral.wrap('right');
- local belt = peripheral.wrap('right');
- local items
- --monitor.setCursorPos(1,1);
- --monitor.setTextScale(0.5);
- redstone.setOutput(beltInvertorSide, false)
- --monitor.write('Detecting...');
- redstone.setOutput(readyChestSide, true);
- redstone.setOutput(seedInputSide, true);
- local ticksWithoutItem = 0;
- print('Detecting')
- while true do
- items = belt.list();
- if #items > 0 then
- ticksWithoutItem = 0;
- --monitor.clear();
- local item = belt.getItemDetail(1);
- if (item.name ~= grownCrystalName) then
- print("Crystal is not ready, another iteration");
- redstone.setOutput(beltInvertorSide, true);
- os.sleep(4);
- redstone.setOutput(beltInvertorSide, false)
- else
- print("Crystal is ready!");
- redstonePulse(readyChestSide);
- redstonePulse(seedInputSide);
- end
- else
- ticksWithoutItem=ticksWithoutItem+1;
- if (ticksWithoutItem > 600) then
- print("No items detected on the belt for 600 ticks, requesting another item");
- redstonePulse(seedInputSide);
- ticksWithoutItem = 0;
- end
- end
- os.sleep(0.1);
- end
Advertisement
Add Comment
Please, Sign In to add comment