Skip to main content

Countdown

Countdown is a useful class for managing, well, countdown. It uses Rbxutil's Timer internally.

Functions

Simple

Countdown.Simple(
StartCountnumber,
CheckFunction(Countnumber) → boolean,
Intervalnumber?,
DecrementNumbernumber?,
StartsNowboolean?
) → any

Creates 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

Countdown.new(
Intervalnumber,
StartingCountnumber
) → Countdown

Types

interface Countdown {
TimerTimer--

the Timer object, should be used for modifying things such as the Interval, TimeFunction, UpdateSignal and AllowDrift.

Countnumber--

The current number the countdown is at

MaxCountnumber--

The maximum the count can reach

Incrementnumber--

The amount that the count decreases every tick

OnFinishSignal--

Fires whenever the count reaches 0

TickSignal<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.

StartedSignal--

Fires whenever the :Start() or :StartNow() method is called.

StoppedSignal--

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.

Show raw api
{
    "functions": [
        {
            "name": "Simple",
            "desc": "Creates a simple timer that returns a promise. Every single interval (default of 1 second), the check function is ran.\nThe check function will have as a parameter a Count, indicating the current count of the timer. The check function\nshould return a boolean, indicating if it will keep running. A DecrementNumber can be provided (defaults to 1) which\nsays how much the timer should decrease the count everytime the CheckFunction is ran.\nIf StartNow is true, the check function will run immediately.\nThe returned promise resolves once the timer reaches 0 and it can be canceled.",
            "params": [
                {
                    "name": "StartCount",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "CheckFunction",
                    "desc": "",
                    "lua_type": "(Count: number) -> boolean"
                },
                {
                    "name": "Interval",
                    "desc": "",
                    "lua_type": "number?"
                },
                {
                    "name": "DecrementNumber",
                    "desc": "",
                    "lua_type": "number?"
                },
                {
                    "name": "StartsNow",
                    "desc": "",
                    "lua_type": "boolean?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "any\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 64,
                "path": "src/Countdown/init.luau"
            }
        },
        {
            "name": "new",
            "desc": "Creates a new countdown object.",
            "params": [
                {
                    "name": "Interval",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "StartingCount",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Countdown\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 97,
                "path": "src/Countdown/init.luau"
            }
        },
        {
            "name": "Stop",
            "desc": "Stops the countdown ",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 134,
                "path": "src/Countdown/init.luau"
            }
        },
        {
            "name": "StartNow",
            "desc": "Starts the countdown and fires the .Tick signal immediately. ",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 144,
                "path": "src/Countdown/init.luau"
            }
        },
        {
            "name": "Start",
            "desc": "Starts the countdown. ",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 154,
                "path": "src/Countdown/init.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Destroys the countdown instance.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 164,
                "path": "src/Countdown/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "Countdown",
            "desc": "",
            "fields": [
                {
                    "name": "Timer",
                    "lua_type": "Timer",
                    "desc": "the [Timer](https://sleitnick.github.io/RbxUtil/api/Timer) object, should be used for modifying things such as the Interval, TimeFunction, UpdateSignal and AllowDrift."
                },
                {
                    "name": "Count",
                    "lua_type": "number",
                    "desc": "The current number the countdown is at"
                },
                {
                    "name": "MaxCount",
                    "lua_type": "number",
                    "desc": "The maximum the count can reach"
                },
                {
                    "name": "Increment",
                    "lua_type": "number",
                    "desc": "The amount that the count decreases every tick"
                },
                {
                    "name": "OnFinish",
                    "lua_type": "Signal",
                    "desc": "Fires whenever the count reaches 0"
                },
                {
                    "name": "Tick",
                    "lua_type": "Signal<number>",
                    "desc": "Same as the [Timer.Tick](https://sleitnick.github.io/RbxUtil/api/Timer/#Tick) property, but with the guarantee that it will fire after the count updates, it also returns the current count as a parameter."
                },
                {
                    "name": "Started",
                    "lua_type": "Signal",
                    "desc": "Fires whenever the :Start() or :StartNow() method is called."
                },
                {
                    "name": "Stopped",
                    "lua_type": "Signal",
                    "desc": "Fires whenever :Stop() is called (or the countdown finished)."
                }
            ],
            "source": {
                "line": 47,
                "path": "src/Countdown/init.luau"
            }
        }
    ],
    "name": "Countdown",
    "desc": "Countdown is a useful class for managing, well, countdown. It uses [Rbxutil's Timer](https://sleitnick.github.io/RbxUtil/api/Timer) internally.",
    "source": {
        "line": 53,
        "path": "src/Countdown/init.luau"
    }
}