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: Can someone

Previous Thread :: Next Thread 
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
29 Sep 2012 09:39 PM
Explain coroutines to me?
I get the basic concept (sorta? o.O)
But why not just call the function?
Only answer I can think of is that you can stop a coroutine.
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
29 Sep 2012 09:41 PM
http://wiki.roblox.com/index.php/Coroutines
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
29 Sep 2012 09:41 PM
My personal favorite coroutine: delay.

function lol()

wait(10)

print("Hi")


end


delay(0, function() lol() end)

print("Hehe")

output: Hehe

10 seconds later

output: Hehe
Hi
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
29 Sep 2012 09:42 PM
@Boy,
I read that ;o
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
29 Sep 2012 09:47 PM
http://wiki.roblox.com/index.php/Beginners_Guide_to_Coroutines
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
29 Sep 2012 09:48 PM
@Black,
Ty <3
Report Abuse
AIAdvance is not online. AIAdvance
Joined: 28 Sep 2012
Total Posts: 18
29 Sep 2012 09:49 PM
function Fun()print(":D")end -- Just a simple function
CoCre = coroutine.create(Fun) -- Renames & turns Fun into a coroutine
coroutine.resume(CoCre) -- Runs the coroutine
print("Win")

There Win would print after :D but only because Win's print was mentioned after the coroutine resume, but they both played at the same time, if you were to add wait(1) before print(":D") Win would print first.

Coroutines basicly take all the code inside the function, and run it seperately, and you'll probably most commonly see it used like

coroutine.resume(coroutine.create(function()
-- Code
end))

Just because most people don't call coroutines more then once, 'cause they're mostly used for multiple loops (At least that's why I use them.)

Also good for script/ commands in admin so you can run loops in them without messing anything up.

If code inside a coroutine errors, the script will still continue, since coroutines basicly create their own scripts.

Any questions?
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
29 Sep 2012 09:50 PM
Np. :3 Read his ^ lolol.
Report Abuse
AIAdvance is not online. AIAdvance
Joined: 28 Sep 2012
Total Posts: 18
29 Sep 2012 09:50 PM
Lol... I took so long to type that there's now 7 replies above it xD
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
29 Sep 2012 09:52 PM
@AI,
Ty for taking time to write that, if there's something on the page that I don't understand, I'll ask you :P
Report Abuse
AIAdvance is not online. AIAdvance
Joined: 28 Sep 2012
Total Posts: 18
29 Sep 2012 09:53 PM
You're welcome :P
Think you can solve my problem on global functions? x3
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
29 Sep 2012 10:01 PM
@AI,
wat? :3
You mean _G?
_G["printfunc"] = (function (string)
print(tostring(string))
end)


In another script:
_G.printfunc(stuff)

I think :o
Only studied _G once, that was like, 2 months ago maybe o.O
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
29 Sep 2012 10:03 PM
Disregard my last question x3
I didn't read your thread,
I thought you just had a spontaneous question :P
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
29 Sep 2012 10:09 PM
Not question >:O
I meant
"Disregard my last post"
Report Abuse
AIAdvance is not online. AIAdvance
Joined: 28 Sep 2012
Total Posts: 18
29 Sep 2012 10:10 PM
xD
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Sep 2012 10:15 PM
How is coroutines difficult to understand? I got it in a heart beat...
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
29 Sep 2012 10:17 PM
@Miz,
So because you can do it means it's easy for everyone...?
Also, the original wiki page didn't explain a lot, the beginners guide is a lot better.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
29 Sep 2012 10:34 PM
No, I did not say that. It's just that I don't see why it's an advanced topic to learn. Really easy for me. So I don't get how it's hard for you...

What don't you understand? Which coroutine you don't get? I'll explain it.
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
29 Sep 2012 10:36 PM
@Miz,
I understand it now,
The coroutine's page just doesn't have enough information for what I want to do.
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
29 Sep 2012 10:39 PM
HOORAH! Random post #1. You mad readers? Lolololol.
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