of     2   
chevron_rightchevron_rightchevron_right

crazyman32
#64225817Monday, March 12, 2012 8:53 PM GMT

Let's say coroutine ABC is currently running and happens to have a loop that goes on forever. How would I stop the coroutine--completely terminate it--from outside the function itself?
nate890
#64226042Monday, March 12, 2012 8:56 PM GMT

Can't you use coroutine.yield?
rhinoBrass
#64226065Monday, March 12, 2012 8:56 PM GMT

Windows Task Manager. -Brassrhino-
rhinoBrass
#64226165Monday, March 12, 2012 8:58 PM GMT

Fun Fact: I don't know what the Hell I'm talking about. -Brassrhino-
crazyman32
#64226253Monday, March 12, 2012 8:59 PM GMT

ABC = coroutine.create(function() while (true) do wait(1) print(time()) end end) coroutine.resume(ABC) wait(1.5) Now I need code here to terminate ABC.
buddy249950
#64226661Monday, March 12, 2012 9:04 PM GMT

You could always remove the script with :Destory()
nate890
#64226681Monday, March 12, 2012 9:05 PM GMT

ABC=coroutine.create(function() coroutine.yield(ABC) end) coroutine.resume(ABC)
nate890
#64226721Monday, March 12, 2012 9:05 PM GMT

Buddy, you can't stop the executing of code outside of a script.
Altruist
#64226740Monday, March 12, 2012 9:06 PM GMT

Why not just coroutine.yield(ABC)? Technically it stops it.
nate890
#64226763Monday, March 12, 2012 9:06 PM GMT

Oh, "outside the function itself". No clue.
Altruist
#64226794Monday, March 12, 2012 9:06 PM GMT

blargh late post. F L O O D C H E C K K C E H C D O O L F
gamehero
#64227601Monday, March 12, 2012 9:17 PM GMT

This is the only way I know how to do it. request_stop = false ABC = coroutine.create(function() while (true) do wait(1) print(time()) if request_stop == true then break end end end) coroutine.resume(ABC) wait(3) request_stop = true print("Stop!!!!! >:O")
iZ0mGeD
#64228008Monday, March 12, 2012 9:22 PM GMT

O_o
OptimalCode
#64228099Monday, March 12, 2012 9:23 PM GMT

Why not try a variable? able = true ABC = coroutine.create(function() while (able) do wait(1) print(time()) end end) coroutine.resume(ABC) wait(1.5) able=false
darkkiller5555
#64228121Monday, March 12, 2012 9:23 PM GMT

I'd do it gamehero's way. I can't think of any other out-of-function way to do it.
andymewborn
#64228190Monday, March 12, 2012 9:24 PM GMT

Does "coroutine.pause()" exists? Sorry I never use these.
crazyman32
#64228290Monday, March 12, 2012 9:25 PM GMT

gamehero's way would have been the way for this BUT... ... the code is dynamic and could be anything. I'm making a plugin that automatically executes scripts, but I need a button to terminate scripts too. Therefore, I can't easily just insert variables into the already-existing source code like that.
FlyScript
#64228364Monday, March 12, 2012 9:26 PM GMT

I'd say remove it with a master script, or an 'if' event, if blah blah blah happens script.Parent.ABC:Remove() ABC would be the name of the coroutine script itself, in the same parent as the master script/script to destroy it. Infact, you could just have in the coroutine itself, if blahblahblah happnens, script.Remove or if you might want to run it later, :Clone(game.Lighting) and then put it in in a other place. if blahblahblah happens game.Lighting.ABC:Clone(game.Workspace)
FlyScript
#64228444Monday, March 12, 2012 9:27 PM GMT

BTW, love your games, mind promoting mine a little, seeing as I have been S-O-O-O-O helpful and all ;)
OptimalCode
#64228464Monday, March 12, 2012 9:27 PM GMT

Confused o:
nate890
#64228510Monday, March 12, 2012 9:28 PM GMT

Gamehero's wouldn't stop the coroutine, it would stop the loop inside of the coroutine. coroutine.yield would suspend the coroutine.
SDuke524
#64229089Monday, March 12, 2012 9:37 PM GMT

> Therefore, I can't easily just insert variables into the already-existing source code like that. Yes you can.
crazyman32
#64260273Tuesday, March 13, 2012 11:07 AM GMT

SDuke, not really. The code could be anything, and there are multiple ways to keep a script going forever; not just loops.
FlyScript
#64269865Tuesday, March 13, 2012 6:35 PM GMT

Like I said, make the coroutine INSIDE s script itself, maybe use blahblahblha else end ? or you could have it as a loop, and make it run until a certain variable changes. e.g. have a boolean value and scriot like this: b = game.Workspace.MyBoolean while b true do [INSERT COROUTINE HERE] end then ahve elsewear in the SAME SCRIPT. if such and such happens b = false end That might work.
nate890
#64270368Tuesday, March 13, 2012 6:46 PM GMT

^A loop isn't associated with every coroutine. Most people posting here don't even understand the difference between coroutines and loops, and the difference is huge.

    of     2   
chevron_rightchevron_rightchevron_right