generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How do coroutine work?

Previous Thread :: Next Thread 
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
09 Aug 2012 06:05 PM
I have no idea..
Report Abuse
WishNite is not online. 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 is not online. 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 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
09 Aug 2012 06:10 PM
Oh wait I mean't coroutine.create
Report Abuse
chickenman158 is not online. chickenman158
Joined: 18 Jan 2011
Total Posts: 915
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 is not online. 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 is not online. 3DShooter
Joined: 04 Aug 2010
Total Posts: 976
09 Aug 2012 06:24 PM
local coroutine = coroutine.create(name)*
Report Abuse
djdjdj is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image