listeners.tick package¶
Provides tick listener based functionality.
-
class
listeners.tick.
Delay
(delay, callback, args=(), kwargs=None, cancel_on_level_end=False)[source]¶ Bases:
core.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.
-
-
class
listeners.tick.
GameThread
(group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None)[source]¶ Bases:
core.WeakAutoUnload
,threading.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
(callback, args=(), kwargs=None, cancel_on_level_end=False)[source]¶ Bases:
core.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.
-
status
¶ Return the status of the repeat.
Return type: RepeatStatus
-