This topic was automatically opened after 7 minutes.
Super excited to get these in my projects already. The task APIs look super easy to use, introduce to novice developers and get them used to new patterns. I too look forward to adopting new patterns in my code involving them. This could also help very much with getting used to deferred events which I initially resisted heavily.
the improved versions of old functions that were particularly discouraged (e.g. delay), especially wait and how it’s based on Heartbeat frequency. Don’t have to write my own boilerplate for that anymore or abuse Promises to get what I need. Same goes with task.spawn for fastSpawn. Less boilerplate and I can use these better versions rather than the ones based on the old frequencies.
Outstanding work. Thank you, engineers!
Also, alas begone, legacy wait. Get outta here.
Question:
Is task.wait()
with no parameters an alternative to using RunService.Heartbeat:Wait()
?
There was this article about not using wait()
with no parameters.
Or should we continue using RunService.Heartbeat:Wait()
?
Yes, task.wait()
is now equivalent to RunService.Heartbeat:Wait()
, and a lot more convenient too. The amount of time spent typing that out saved is astonishing…
Is there any reason you didn’t just change the default behaviours of those functions, and instead add a new task library? Does this have something to do with parallel lua
Anway’s glad that useless old function has now been given a replacement
I believe this should answer your question:
The reason using wait() with no parameters is bad is because it (task.wait()) is
i’m wondering if this wait()
alternative:
function Halt(Duration)
--// Arguments: (Duration[Number])
Duration = (Duration or 0)
local cur = 0;
if (Duration <= 0) then
Heartbeat:Wait();
end
while cur < Duration do
cur += Heartbeat:Wait();
end
return cur;
end
is the same as:
task.wait()
(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)
It should be noted that results of these aren’t equivalent:
task.spawn(function()
print(task.wait())
end)
task.spawn(function()
print(game:GetService"RunService".Heartbeat:Wait())
end)
task.wait()
's DeltaTime result will count from the time of the call, while Heartbeat:Wait()
will count from the previous Heartbeat.
Also, task.delay()
causes a crash instead of an error.
Is this almost like some kind of task manager for Studio?
Because you can’t do Heartbeat:Wait(2)
since :Wait()
function on RBXScriptSignal
s doesn’t take any arguments?
What is the fastSpawn pattern?
So what’s the difference of task.wait, task.spawn, and wait, spawn
?
I’m still struggling to understand use cases for task.defer
. I understand how it works and how it fits into the library but under what circumstances would you want code to run at some predetermined point later in time that you have no control over? Is there any real benefit in doing so?
I also don’t understand this. How is it not a replacement for spawn? And wasn’t the original fastspawn method implemented with BindableEvent
s? With deferred events that would mean that it wouldn’t be an immediate resumption, unless of course I’m misinterpreting the meaning of “fastSpawn pattern”.
deferred on Nevermore (originally fastSpawn)
“An expensive way to spawn a function. However, unlike spawn(), it executes on the same frame, and unlike coroutines, does not obscure errors.”
(edit: changed link to folder with README, was originally set to a release branch)
I assume for legacy purposes, old games experiences whose behavior could be compromised if they just redo the old functions.
Will documentation for task
happen soon? I’d expect it to be available on the developer hub for more info and on task scheduler article on availability of a class (aka today).
Hmmm… what is happening??
Is this basically like coroutine
? I mean, I am a builder, not knowing much about these, but isn’t it the same thing?
Updated my “Spawn is Evil” article to just point to the new task
library. Glad that this problem finally has an easy solution that doesn’t require several paragraphs to explain!
Wanted to test the accuracy to see if task.wait
has any benefits. Here’s the results of averaging the delta time of each function 20 times:
task.wait
really is EXACTLY Heartbeat:Wait()
, only much easier to type out. For anyone asking the differences between wait
and task.wait
, the answer is accuracy.