listeners.tick package¶
Provides tick listener based functionality.
- class listeners.tick.Delay(*args, **kwargs)[source]¶
Bases:
WeakAutoUnload
Execute a callback after a given delay.
- __init__(delay, callback, args=(), kwargs=None, cancel_on_level_end=False)[source]¶
Initialize the delay.
- Parameters:
delay (float) – The delay in seconds.
callback – A callable object that should be called after the delay expired.
args (tuple) – Arguments that should be passed to the callback.
kwargs (dict) – Keyword arguments that should be passed to the callback.
cancel_on_level_end (bool) – Whether or not to cancel the delay at the end of the map.
- Raises:
ValueError – Raised if the given callback is not callable.
- cancel()[source]¶
Cancel the delay.
- Raises:
ValueError – Raised if the delay is not running.
- args¶
Arguments to pass to the callback.
- callback¶
Callback to call when the delay expired.
- cancel_on_level_end¶
Whether or not to cancel the delay at the end of the map.
- delay¶
Delay in seconds.
- exec_time¶
Time when the delay will be executed.
- kwargs¶
Keyword arguments to pass to the callback.
- property time_elapsed¶
Return the amount of time (in seconds) since the Delay started.
- Return type:
- class listeners.tick.GameThread(*args, **kwargs)[source]¶
Bases:
WeakAutoUnload
,Thread
A subclass of
threading.Thread
that throws a warning if the plugin that created the thread has been unloaded while the thread is still running.
- class listeners.tick.Repeat(*args, **kwargs)[source]¶
Bases:
AutoUnload
Class used to create and call repeats.
- __init__(callback, args=(), kwargs=None, cancel_on_level_end=False)[source]¶
Store all instance attributes.
- Parameters:
callback – A callable object that should be called at the end of each loop.
args (tuple) – Arguments that should be passed to the callback.
kwargs (dict) – Keyword arguments that should be passed to the callback.
cancel_on_level_end (bool) – Whether or not to cancel the repeat at the end of the map.
- Raises:
ValueError – Raised if the given callback is not callable.
- extend(adjustment)[source]¶
Add to the number of loops to be made.
- Parameters:
adjustment (int) – The number of loops to be added to the limit.
- Raises:
ValueError – Raised if given adjustment is not a positive integer.
- reduce(adjustment)[source]¶
Reduce the number of loops to be made.
- Parameters:
adjustment (int) – The number of loops to be removed from the limit.
- Raises:
ValueError – Raised if given adjustment is not a positive integer.
- start(interval, limit=inf, execute_on_start=False)[source]¶
Start the repeat loop.
- Parameters:
interval (float) – The time (in seconds) for each loop.
limit (int) – The maximum number of times to loop. If
math.inf
is passed, there is no limit, and the Repeat will loop indefinitely.execute_on_start (bool) – Whether to execute the callback when the Repeat is started. Note that this does not affect the ‘limit’ as the number of loops will remain the same.
- property original_loops¶
Return the number of loops the repeat has been started with.
- Return type:
- property status¶
Return the status of the repeat.
- Return type: