Repository navigation
API Timers
| Import | from proleak import timers |
Timers driven by the game's frame loop. All callbacks run on the main thread.
| Class | |
|---|---|
Timer |
Handle returned by every, after and on_frame. |
| Returns | Function | |
|---|---|---|
Timer | Callable |
every(seconds: float, fn: Callable[[], None] | None = None) |
Calls fn every seconds. |
Timer | Callable |
after(seconds: float, fn: Callable[[], None] | None = None) |
Calls fn once, seconds from now. |
Timer |
on_frame(fn: Callable[[], None]) |
Call fn once per frame. |
every(seconds: float, fn: Callable[[], None] | None = None) -> Timer | Callable
Calls fn every seconds.
Called with fn, it returns the Timer. Used as a decorator
(@timers.every(5)), it starts the timer and leaves the function as it is.
after(seconds: float, fn: Callable[[], None] | None = None) -> Timer | Callable
Calls fn once, seconds from now.
Called with fn, it returns the Timer; used as a decorator, it
starts the timer and leaves the function as it is.
on_frame(fn: Callable[[], None]) -> Timer
Call fn once per frame. Keep it short: it shares the frame with the game.
Handle returned by every, after and on_frame.
| Type | Property | |
|---|---|---|
str |
owner |
The id of the plugin that started it. |
Callable[[], None] |
fn |
The function it calls. |
float | None |
interval |
Seconds between calls; None for a timer that calls once or every frame. |
bool |
cancelled |
True once it was cancelled or, for a timer that calls once, once it ran. |
| Returns | Method | |
|---|---|---|
None |
cancel() |
Stop the timer. |
owner: str
The id of the plugin that started it.
fn: Callable[[], None]
The function it calls.
interval: float | None
Seconds between calls; None for a timer that calls once or every frame.
cancelled: bool
True once it was cancelled or, for a timer that calls once, once it ran.
cancel() -> None
Stop the timer. Safe to call twice.
Using ProLeak
Features
Tutorial
- Your first plugin
- Plugin basics
- Handling events
- Plugin settings
- User interface
- Players, units and game data
- Purchases, signals and pings
- Chat, camera, input and more
- Cosmetics
- Game modes
- Game updates
- Publishing plugins
Reference