Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way how to shorthand a coroutine?

Asked by 8 years ago

Lets say I want to have a process run in the background once, and I don't need to reference it later.

Is it possible to create a coroutine without a key variable?

like how you can call a function like

function() 
--do somehting
end

Is there a way to do this with coroutines? I'd imagine it would be along the lines of

coroutine.resume(coroutine.create(function()
--do something
end))
1
you have it right there. what is your question? 1waffle1 2908 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

You can do things such as using spawn() or delay(), but there is no actual coroutine.resume(coroutine.create()) direct shorthand.

Ad
Log in to vote
0
Answered by 8 years ago

Actually there is a way to shorthand it: coroutine.wrap The way to use it would be

local example = coroutine.wrap(function()
print ("a")
end)

Basically it takes a coroutine and assigns it a function. To use it you would just call the function you assigned to it with whatever parameters requires. Hope this helps. :)

0
I'm kinda looking to skip the assigning feature and just run it without any assigning needed. randomsmileyface 375 — 8y

Answer this question