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

Best Practice For Waiting Between Multiple Functions?

Asked by
blowup999 659 Moderation Voter
4 years ago

In one of my scripts I want to wait 1 second before doing something, 5 seconds before another, 15 seconds before another, and renderstep a 4th.

Would best practice be to renderstep the one function, and then spawn() another function to its own thread such that it waits 1 second every time and when timesRun % 5 call the 2nd when timesRun % 15 call the 3rd? Or should I do all of that in a single renderstep? Or (and I'm not familiar with this) can I somehow utilize coroutines in here to remove the spawn()?

I am able to do any of these options, I'm just looking for a best practice to minimize cpu utilization because these are going to be running/yielding constantly. Thank you for any help.

1
your question is confusing me, could you possibly DM me on discord about this? Its Matt.#8009 MattyGamin 41 — 4y
0
I've decided that for small enough functions, spawn() is a waste of a thread as it will basically yield constantly, therefore I will renderstep them. blowup999 659 — 4y

Answer this question