Too Long Without Yielding
Abstract 22 Feb 2012
I need some help with my program. What it should do is,output redstone to the left, if redstone comes from the front, stop outputting redstone to the right wait and reboot. this is my code:
startup:
startup:
while true do shell.run"redside" endredside:
redstone.setOutput("right", true) if redstone.getInput("front", true) then redstone.setOutput("right", false) sleep(10) os.restart() endbut if I reboot now, it works for only a couple of seconds and a error pops up which says 'Too long without yielding'. What did I do wrong?
Casper7526 22 Feb 2012
When your code just loops endlessly without yielding for a few seconds, you receive that error.
You should use a pullevent to only check when redstone is changed instead.
startup:
You should use a pullevent to only check when redstone is changed instead.
startup:
redstone.setOutput("right", true) while true do event, param = os.pullEvent() if event == "redstone" and redstone.getInput("front") == true then redstone.setOutput("right", false) sleep(10) redstone.setOutput("right", true) end end
Abstract 22 Feb 2012
Casper7526, on 22 February 2012 - 03:28 PM, said:
When your code just loops endlessly without yielding for a few seconds, you receive that error.
You should use a pullevent to only check when redstone is changed instead.
startup:
You should use a pullevent to only check when redstone is changed instead.
startup:
redstone.setOutput("right", true) while true do event, param = os.pullEvent() if event == "redstone" and redstone.getInput("front") == true then redstone.setOutput("right", false) sleep(10) redstone.setOutput("right", true) end end
Don't know why I've typed everything like you
EDIT: works, had a spelling mistake />