Guarantee an event listener to be called before other listeners of the same event?
Posted: Thu Jul 02, 2015 1:12 pm
How would I ensure that my player_spawn event listener gets called before others?
I'm trying to reset every player's gravity to 1.0 whenever they spawn, and I want to make sure it happens before other player_spawn functions modify the gravity again.
Here's an easy example code of what I have:and I need to make sure that player's gravity gets reset in bar.py before it's reduced by 0.5 in foo.py
I'm trying to reset every player's gravity to 1.0 whenever they spawn, and I want to make sure it happens before other player_spawn functions modify the gravity again.
Here's an easy example code of what I have:
Syntax: Select all
# ../plugins/foo/bar.py
@Event
def player_spawn(game_event):
player = PlayerEntity(index_from_userid(game_event.get_int('userid')))
player.gravity = 1.0
# ../plugins/foo/foo.py
@Event
def player_spawn(game_event):
player = PlayerEntity(index_from_userid(game_event.get_int('userid')))
player.gravity -= 0.5