Jump to content




[QUESTION] [LUA] Coroutines


  • You cannot reply to this topic
4 replies to this topic

#1 anonimo182

  • Members
  • 252 posts
  • LocationIn the universe

Posted 10 October 2012 - 09:49 PM

Can I have two coroutines working at the same time?

#2 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 10 October 2012 - 10:08 PM

What is a coroutines? Or do you just mean programs?

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 October 2012 - 10:20 PM

View Postanonimo182, on 10 October 2012 - 09:49 PM, said:

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.

#4 anonimo182

  • Members
  • 252 posts
  • LocationIn the universe

Posted 10 October 2012 - 10:23 PM

ok, but how can I do that?

#5 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 October 2012 - 10:25 PM

parallel.waitForAny(functionOne, functionTwo)

Check out the documentation on the wiki.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users