events package

Submodules

Module contents

Provides event based functionality.

classevents.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}
classevents.GameEvent

Bases:instance

__getitem__((GameEvent)arg1,(str)arg2)object:

Return an event variables in its proper data type.

__init__()

Raises an exceptionThis 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.

propertydescriptor

Return the event’s descriptor.

propertyname

Returns the event name.

propertyvariables

Return all event variables as a KeyValues instance.

classevents.GameEventDescriptor

Bases:instance

__init__()

Raises an exceptionThis class cannot be instantiated from Python

__reduce__()

Helper for pickle.

propertyevent_id

Return the ID of the event.

propertylocal

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

propertyname

Return the name of the event.

propertyreliable

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

propertyvariables

Return the variables of the event.

@events.Event(*event_names)[source]

Bases:core.AutoUnload

Fired when any event inevent_names is fired on the server.

Parameters:

event_names (str) – An event name or any number ofevent names to register to the decorated function.

The decorated function is passed the following parameters whenan event inevent_names is fired on the server:

Parameters:

game_event (GameEvent) – The fired event.

Examples:

fromeventsimportEvent@Event('player_death')defplayer_died(game_event):# Code...
@Event('round_start','round_freeze_end')defsome_function(game_event):# Code...

See also

Events for a list of supported events per game.