of     2   
chevron_rightchevron_rightchevron_right

Solotaire
#93520563Monday, April 01, 2013 5:31 PM GMT

Which one do you guys find yourself using most often? What are the core differences between them, or are they all pretty similar--do any of them represent a separate thread better than the other? Are the run-times comparable? Making this thread in part because I'd like to get your opinions and in part because there seems to be even less scripting discussion than usual.
Waffle3z
#93520670Monday, April 01, 2013 5:32 PM GMT

Delay has a minimum 1-frame wait-time Spawn is easier to type coroutines have useful methods.
dekkonot
#93520815Monday, April 01, 2013 5:33 PM GMT

I honestly have no idea. I never use any of them, as I'm never in any large projects. ~Not a Moderator, The Makeshift Moderator Team, Dekkonot
zins
#93521095Monday, April 01, 2013 5:36 PM GMT

[ Content Deleted ]
Solotaire
#93521357Monday, April 01, 2013 5:38 PM GMT

"I honestly have no idea. I never use any of them, as I'm never in any large projects." I find myself using them when trying to reduce the total number of scripts in my game, but mostly have used coroutines.
coplox
#93521467Monday, April 01, 2013 5:39 PM GMT

I tend to use coroutines.
patrline5599
#93521895Monday, April 01, 2013 5:43 PM GMT

i used a coroutine for having multiple loops instead of multiple scripts is that the correct way?
iStone4S
#93522024Monday, April 01, 2013 5:44 PM GMT

What does this do, please?
ColorfulBody
#93522154Monday, April 01, 2013 5:45 PM GMT

Coroutines don't create real threads, while delay and spawn do. Delay should only be used when you actually don't want to run it immediately. Otherwise, use spawn.
Solotaire
#93522469Monday, April 01, 2013 5:48 PM GMT

"i used a coroutine for having multiple loops instead of multiple scripts is that the correct way?" If "multiple loops" means at the same time, then yes.
ColorfulBody
#93522588Monday, April 01, 2013 5:49 PM GMT

@Solotaire Use delay when you want to run it in a certain time. Use Spawn when you want to run something in another, real thread. Use coroutines when you just want multithreading.
Sharksie
#93522913Monday, April 01, 2013 5:51 PM GMT

Doesn't spawn wait a frame before running its code?
Solotaire
#93523113Monday, April 01, 2013 5:53 PM GMT

@iStone4S, Here's an example of coroutines to help you understand function printNumbers() for i = 1,3 do print(i) end end routine = coroutine.wrap(printNumbers) routine() printNumbers() that should give you something that looks about like this: >1 >1 >2 >2 >3 >3 If you didn't use a coroutine and just had the following: printNumbers() printNumbers() Your output would be: >1 >2 >3 >4 >5 >6
Snoxicle
#93524023Monday, April 01, 2013 6:01 PM GMT

I use spawn except for some cases where coroutines are needed.
HEAT507
#93543182Monday, April 01, 2013 8:42 PM GMT

text=[[ print(1/1); ]] pcall(function() coroutine.resume(coroutine.create(loadstring(text)); end);
08C
#111225555Tuesday, August 27, 2013 5:40 AM GMT

[ Content Deleted ]
Oysi
#111225910Tuesday, August 27, 2013 5:49 AM GMT

[ Content Deleted ]
nate890
#111231607Tuesday, August 27, 2013 8:45 AM GMT

Coroutines have their own uses. It's best to use Spawn if you want to sneak a thread in there. Delay should only be used if you are trying to delay the thread from starting, otherwise it's best to use the Spawn function.
zars15
#111234727Tuesday, August 27, 2013 10:42 AM GMT

"because there seems to be even less scripting discussion than usual." No, usually there are 0-3 discussions per day. Yesterday everything suddenly changed, and scripters is filled with discussions. And back on topic... I use new threads just hacky stuff, so I could live without them, since they aren't useful for me at all. If you do everything clean and efficient, you shouldn't need new threads.
MemoryAddress
#111238317Tuesday, August 27, 2013 11:59 AM GMT

[ Content Deleted ]
CloneTrooper1019
#111239421Tuesday, August 27, 2013 12:20 PM GMT

I use delay. I could probably use spawn in most cases though.
Maelstronomer
#111243984Tuesday, August 27, 2013 1:53 PM GMT

Multithreading with .create vs new thread entirely - same difference? I use coroutine.resume(coroutine.create(function ...()) end)) because it is cool looking.
Oysi
#111246166Tuesday, August 27, 2013 2:28 PM GMT

[ Content Deleted ]
abaw7
#111246433Tuesday, August 27, 2013 2:32 PM GMT

I used to use coroutine.wrap(function() end)() because I understood Coroutines, and couldn't figure our how the heck Spawn worked. Then, I found out how Spawn worked, went Yay!, and that's my main choice now.
MrgamesNwatch
#111247528Tuesday, August 27, 2013 2:47 PM GMT

I generally use spawn as its simple and does exactly what i need it to do. For example, having and entire model fade: function fadeModel(model) for i,v in pairs(model:GetChildren()) do if v:IsA("BasePart") then Spawn(function() for i = v.Transparency*10,1,0.1 do wait() v.Transpareny= i/10 end end) end end end ~ I choice end)() coroutine.wrap(function() I and used Spawn Yay!, Spawn

    of     2   
chevron_rightchevron_rightchevron_right