game_event
__index
event.{name: string}
-> any
event[{name: string}]
-> any
Returns key value.
Note
Due to game engine design, boolean properties will be returned as integer (0 for false, 1 for true).
Parameters
Name | Type | Description |
---|---|---|
name |
string | Key name |
Usage
attacker = event.attacker;
-- this one is the same
attacker = event:get_int('attacker');
get_name
get_name()
-> string
Returns name of the event.
Usage
function on_game_event(event)
if event:get_name() == 'player_hurt' then
print('someone hurt a player');
end
end
get_int
get_int(val: string)
-> number
Returns the integer value of the key.
Parameters
Name | Type | Description |
---|---|---|
val |
string | Key name |
Usage
function on_player_hurt(event)
local damage = event:get_int('damage');
print('someone hurt a player for' .. damage);
end
get_float
get_float(val: string)
-> number
Returns the float value of the key.
Parameters
Name | Type | Description |
---|---|---|
val |
string | Key name |
Usage
function on_bullet_impact(event)
local pos_x = event:get_float('x');
end
get_bool
get_bool(val: string)
-> bool
Returns the bool value of the key.
Parameters
Name | Type | Description |
---|---|---|
val |
string | Key name |
Usage
function on_player_death(event)
local attackerblind = event:get_bool('attackerblind');
end
get_string
get_string(val: string)
-> string
Returns the string value of the key.
Parameters
Name | Type | Description |
---|---|---|
val |
string | Key name |
Usage
function on_player_death(event)
local weapon = event:get_string('weapon');
end