Minecraft Computercraft – Infinite Loop Redstone Detection with Lua

minecraft-computercraftminecraft-java-edition

I'm trying to make a harvester/planter out of computercraft computers, and I can get a redstone pulse consistent with a crop maturing, but cannot loop my command redstone.getInput("front") to keep checking without the program crashing.

-- Harvest Program
    --inf loop
while true do
    -- Redstatus is just a bool variable
    if RedStatus = redstone.getInput("front") then
    rednet.send(1, "shell.run("Harvest")")
end

Best Answer

Call os.sleep(x) at the end of your loop. The loop will then be executed every x seconds.