events package

Module contents

Provides event based functionality.

class events.EventVarType

Bases: Boost.Python.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 = {'LOCAL': _events.EventVarType.LOCAL, 'STRING': _events.EventVarType.STRING, 'FLOAT': _events.EventVarType.FLOAT, 'LONG': _events.EventVarType.LONG, 'SHORT': _events.EventVarType.SHORT, 'BYTE': _events.EventVarType.BYTE, 'BOOL': _events.EventVarType.BOOL, '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: Boost.Python.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__()
__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[, (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, (Channel)value) → None :

Sets the given key name.

set_string((GameEvent)arg1, (str)key_name, (str)value) → None :

Sets the given key name.

descriptor

Return the event’s descriptor.

name

Returns the event name.

variables

Return all event variables as a KeyValues instance.

class events.GameEventDescriptor

Bases: Boost.Python.instance

__init__()

Raises an exception This class cannot be instantiated from Python

__reduce__()
event_id

Return the ID of the event.

local

Return True if the event is local only (server only).

name

Return the name of the event.

reliable

Return True if the event is sent as a reliable message.

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.