Countdown
Countdown is a useful class for managing, well, countdown. It uses Rbxutil's Timer internally.
Functions
Simple
Countdown.Simple(StartCount: number,CheckFunction: (Count: number) → boolean,Interval: number?,DecrementNumber: number?,StartsNow: boolean?) → anyCreates a simple timer that returns a promise. Every single interval (default of 1 second), the check function is ran. The check function will have as a parameter a Count, indicating the current count of the timer. The check function should return a boolean, indicating if it will keep running. A DecrementNumber can be provided (defaults to 1) which says how much the timer should decrease the count everytime the CheckFunction is ran. If StartNow is true, the check function will run immediately. The returned promise resolves once the timer reaches 0 and it can be canceled.
new
Types
interface Countdown {Timer: Timer--
the Timer object, should be used for modifying things such as the Interval, TimeFunction, UpdateSignal and AllowDrift.
Count: number--
The current number the countdown is at
MaxCount: number--
The maximum the count can reach
Increment: number--
The amount that the count decreases every tick
OnFinish: Signal--
Fires whenever the count reaches 0
Tick: Signal<number>--
Same as the Timer.Tick property, but with the guarantee that it will fire after the count updates, it also returns the current count as a parameter.
Started: Signal--
Fires whenever the :Start() or :StartNow() method is called.
Stopped: Signal--
Fires whenever :Stop() is called (or the countdown finished).
}Creates a new countdown object.
Stop
Countdown:Stop() → ()Stops the countdown
StartNow
Countdown:StartNow() → ()Starts the countdown and fires the .Tick signal immediately.
Start
Countdown:Start() → ()Starts the countdown.
Destroy
Countdown:Destroy() → ()Destroys the countdown instance.