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

[QUESTION] [LUA] Coroutines

Started by anonimo182, 10 October 2012 - 08:49 PM
anonimo182 #1
Posted 10 October 2012 - 10:49 PM
Can I have two coroutines working at the same time?
jag #2
Posted 10 October 2012 - 11:08 PM
What is a coroutines? Or do you just mean programs?
Lyqyd #3
Posted 10 October 2012 - 11:20 PM
Can I have two coroutines working at the same time?

Technically, no. But you can run one and then the other, back and forth, in rapid succession. They will appear to be running at the same time. This is what the parallel API does (you pass it two functions to create the coroutines with), so that would be a good place to start.
anonimo182 #4
Posted 10 October 2012 - 11:23 PM
ok, but how can I do that?
Lyqyd #5
Posted 10 October 2012 - 11:25 PM
parallel.waitForAny(functionOne, functionTwo)

Check out the documentation on the wiki.