This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
GrayTheWolf's profile picture

Elevator code; too long without yielding.

Started by GrayTheWolf, 05 June 2013 - 11:49 PM
GrayTheWolf #1
Posted 06 June 2013 - 01:49 AM
I have been getting this error also.
I am making an elevator using bundled cables. You press a button and it sends the minecart up to that same color floor.

The code runs for a bit, and then crashes giving the "too long without yielding" error.

Here it is:

while true do
if redstone.testBundledInput("right", colors.orange) then
redstone.setBundledOutput("left", 0)
redstone.setBundledOutput("left", colors.orange)
end
if redstone.testBundledInput("right", colors.magenta) then
redstone.setBundledOutput("left", 0)
redstone.setBundledOutput("left", colors.magenta)
end
end
restart("")

Hoping someone can give some insight as to why I am getting this error. And hopefully it will help OP also.
Lyqyd #2
Posted 06 June 2013 - 01:52 AM
Split into new topic. It would have been best to post in the New Members topic.

Try adding the line `os.pullEvent("redstone")` just below the `while true do` and before your first if statement. That will cause it to pause and wait for changes in redstone state.
GrayTheWolf #3
Posted 06 June 2013 - 01:56 AM
Split into new topic. It would have been best to post in the New Members topic.

Try adding the line `os.pullEvent("redstone")` just below the `while true do` and before your first if statement. That will cause it to pause and wait for changes in redstone state.

Thanks. I will try that.


Edit:

Thanks so much! That fixed it!