Hey, so I’m back again with another module. A module like this one might already exist but I couldnt find any topics on this really, so I made my own. This one is for creating timed cooldowns. You can also hook your own functions onto each Tick of the cooldown and the End of the cooldown. The module can be found here, and the API documentation is down below:
API 1.0
Cooldown.new(lifetime, tickrate, tickfunc, finishfunc)
Returns a new Cooldown.
lifetime
- How much time the cooldown takes.
tickrate
(Optional) - How many seconds between each tick of the cooldown. The default is 1.
tickfunc
(Optional) - A function connected to the cooldown. It is called each time the cooldown ticks.
finishfunc
(Optional) - A function connected to the cooldown. It is called once the cooldown finishes.
Cooldown:Start()
Starts the cooldown.
void
- This function takes in no parameters.
Cooldown:Stop()
Stops the cooldown if it is already started.
void
- This function takes in no parameters.
Cooldown:IsRunning()
Returns true or false depending on if the cooldown is active or not.
return
- Returns self.IsRunning
Cooldown:GetTimeLeft()
Returns how much time is left before the cooldown ends.
return
- Returns self.TimeLeft
Cooldown:GetMaxTime()
Returns the lifetime of the cooldown (How many seconds it was originally counting down from).
return
- Returns self.Lifetime
Cooldown:Tick(func)
Binds a user-created function to the tick connection.
func
- A function that will run each time the cooldown ticks.
Cooldown:Finish(func)
Binds a user-created function to the finish connection.
func
- A function that will run as soon as the cooldown is finished.