Is there a function that makes a thread wait for a certain number of tics/seconds?

LionOte

Feline
I'm trying to make an addon, but I discovered that there's no wait() or delay() function. I can't figure out any other way to get my script to yield for a few seconds, and there wasn't a function like that documented on the Wiki. Is there a function that can make a script wait for a few seconds or tics?
 
I'm trying to make an addon, but I discovered that there's no wait() or delay() function. I can't figure out any other way to get my script to yield for a few seconds, and there wasn't a function like that documented on the Wiki. Is there a function that can make a script wait for a few seconds or tics?
There is, and it's called prematurely returning.

Jokes aside, there really isn't such a function. Not much can be done about that other than waiting for the next hook call or keeping a timer variable. Apologies for the late reply.
 
You must be new to SRB2, JS -- welcome! In SRB2, time isn't counted in milliseconds, it's counted in tics. There are 35 tics per second. Please check the wiki to confirm details like this before trying to help others next time 😀
 
I'm trying to make an addon, but I discovered that there's no wait() or delay() function. I can't figure out any other way to get my script to yield for a few seconds, and there wasn't a function like that documented on the Wiki. Is there a function that can make a script wait for a few seconds or tics?
Ok so basically
The game runs at 35 tics per seconds, and Hooks will run your functions every tic. (not all Hooks act the same: the PlayerThink Hook will run the function once for every player in game every tic, the MobjMoveBlocked Hook only runs when an object is blocked by something, etc)
With this in mind, you can, for example, create a variable, set it to for example 35 (which will make a delay of 1 second), and decrease it by 1 every frame, and then execute something once it reaches 0.
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top