events package¶
Submodules¶
Module contents¶
Provides event based functionality.
- class events.EventVarType¶
Bases:
enum
- BOOL = _events.EventVarType.BOOL¶
- BYTE = _events.EventVarType.BYTE¶
- FLOAT = _events.EventVarType.FLOAT¶
- LOCAL = _events.EventVarType.LOCAL¶
- LONG = _events.EventVarType.LONG¶
- SHORT = _events.EventVarType.SHORT¶
- STRING = _events.EventVarType.STRING¶
- UINT64 = _events.EventVarType.UINT64¶
- WSTRING = _events.EventVarType.WSTRING¶
- names = {'BOOL': _events.EventVarType.BOOL, 'BYTE': _events.EventVarType.BYTE, 'FLOAT': _events.EventVarType.FLOAT, 'LOCAL': _events.EventVarType.LOCAL, 'LONG': _events.EventVarType.LONG, 'SHORT': _events.EventVarType.SHORT, 'STRING': _events.EventVarType.STRING, 'UINT64': _events.EventVarType.UINT64, 'WSTRING': _events.EventVarType.WSTRING}¶
- values = {0: _events.EventVarType.LOCAL, 1: _events.EventVarType.STRING, 2: _events.EventVarType.FLOAT, 3: _events.EventVarType.LONG, 4: _events.EventVarType.SHORT, 5: _events.EventVarType.BYTE, 6: _events.EventVarType.BOOL, 7: _events.EventVarType.UINT64, 8: _events.EventVarType.WSTRING}¶
- class events.GameEvent¶
Bases:
instance
- __getitem__((GameEvent)arg1, (str)arg2) object : ¶
Return an event variables in its proper data type.
- __init__()¶
Raises an exception This class cannot be instantiated from Python
- __reduce__()¶
Helper for pickle.
- __setitem__((GameEvent)arg1, (str)arg2, (object)arg3) None : ¶
Sets an event variable.
- get_bool((GameEvent)arg1, (str)arg2[, (bool)default_value=False]) bool : ¶
Returns the value of the key name as a bool.
- get_float((GameEvent)arg1, (str)arg2[, (float)default_value=0.0]) float : ¶
Returns the value of the key name as a float.
- get_int((GameEvent)arg1, (str)arg2[, (_engines._sound.Channel)default_value=0]) int : ¶
Returns the value of the key name as an int.
- get_string((GameEvent)arg1, (str)arg2[, (str)default_value='']) object : ¶
Returns the value of the key name as a string.
- is_empty((GameEvent)arg1[, (str)key_name=None]) bool : ¶
Returns true if the given key exists. If no key name was passed, it will check if the whole event is empty.
- is_local((GameEvent)arg1) bool : ¶
Returns true if the event never networked.
- is_reliable((GameEvent)arg1) bool : ¶
Returns true if the event handled reliably.
- set_bool((GameEvent)arg1, (str)key_name, (bool)value) None : ¶
Sets the given key name.
- set_float((GameEvent)arg1, (str)key_name, (float)value) None : ¶
Sets the given key name.
- set_int((GameEvent)arg1, (str)key_name, (_engines._sound.Channel)value) None : ¶
Sets the given key name.
- set_string((GameEvent)arg1, (str)key_name, (str)value) None : ¶
Sets the given key name.
- property descriptor¶
Return the event’s descriptor.
- property name¶
Returns the event name.
- property variables¶
Return all event variables as a KeyValues instance.
- class events.GameEventDescriptor¶
Bases:
instance
- __init__()¶
Raises an exception This class cannot be instantiated from Python
- __reduce__()¶
Helper for pickle.
- property event_id¶
Return the ID of the event.
- property local¶
Return True if the event is local only (server only).
- property name¶
Return the name of the event.
- property reliable¶
Return True if the event is sent as a reliable message.
- property variables¶
Return the variables of the event.
- @events.Event(*event_names)[source]¶
Bases:
core.AutoUnload
Fired when any event in
event_names
is fired on the server.- Parameters:
event_names (str) – An event name or any number of event names to register to the decorated function.
The decorated function is passed the following parameters when an event in
event_names
is fired on the server:- Parameters:
game_event (GameEvent) – The fired event.
Examples:
from events import Event @Event('player_death') def player_died(game_event): # Code...
@Event('round_start', 'round_freeze_end') def some_function(game_event): # Code...
See also
Events for a list of supported events per game.