Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
| |
|
WishNite
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 15828 |
|
|
| 09 Aug 2012 06:07 PM |
http://wiki.roblox.com/index.php/Coroutines
Coroutines are essentially creating a new script within the script, meaning you can have things such as multiple loops going at the same time. |
|
|
| Report Abuse |
|
|
Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
|
| 09 Aug 2012 06:09 PM |
Actually explaining them, not just linking them to the wiki..
Also I meant coroutine.new
|
|
|
| Report Abuse |
|
|
Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
|
| 09 Aug 2012 06:10 PM |
| Oh wait I mean't coroutine.create |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2012 06:12 PM |
I think I already answered this today... Corountines make new threads which allow for multiple items to be run at a time. Not super useful in Roblox, as each script seems to have it's own thread. (Correct me if I am wrong). It can be useful for launching multiple loops in one script. |
|
|
| Report Abuse |
|
|
3DShooter
|
  |
| Joined: 04 Aug 2010 |
| Total Posts: 976 |
|
|
| 09 Aug 2012 06:23 PM |
I prefer spawn, but coroutine will allow you to pretty much the same thing, I don't know which is more effecient.
function name(arg) --stuff end local coroutine = coroutine(name) coroutine(arg)
will allow you to run name on it's own thread.
|
|
|
| Report Abuse |
|
|
3DShooter
|
  |
| Joined: 04 Aug 2010 |
| Total Posts: 976 |
|
|
| 09 Aug 2012 06:24 PM |
| local coroutine = coroutine.create(name)* |
|
|
| Report Abuse |
|
|
djdjdj
|
  |
| Joined: 21 Mar 2008 |
| Total Posts: 10 |
|
|
| 09 Aug 2012 06:34 PM |
here is a good example script involving coroutine local a = coroutine.create(function() while wait() do print("hi") end end) coroutine.resume(a) |
|
|
| Report Abuse |
|
|