Addon Details

Watch - Add Favorite


Does this version work for you?
5
w00ts
w00t!2

Python event call modifier - Version beta

posted on 2008-07-13 06:21:49
by GODJonez


Tags: Hack

Description

Using this script as a module other scripts can add their own event info modifiers to alter event variables at will. The modified event variables are only visible for Python scripts, ESS scripts only get the original event variables. Note that this script does not actually change the function itself that triggered the event, only allows faking the event variables for other Python addons. If you load this as a script addon (es_load modevents), an example event modifier is applied. This example modifier adds [i]dmg_health[/i] event variable to hold the value that event variable [i]damage[/i] contains in case the game is Day of Defeat: Source. Any Python script can add their own event modifiers by importing modevents module as in [syntax="python"]import modevents[/syntax] To add event modifier to specific event, use add_modder function, for example: [syntax="python"]modevents.add_modder('player_death', my_player_death_modifier)[/syntax] To remove the event modifier, use del_modder function, for example: [syntax="python"]modevents.del_modder('player_death', my_player_death_modifier)[/syntax] The actual event modifier receives one parameter that acts like event_var instance but can be modified as a normal dictionary to change or add event variables. Deleting existing event variables is not possible, but you may set an existing event variable to empty string to simulate it being deleted, for example: [syntax="python"]def my_player_death_modifier(event_var): # swap attacker and victim for player_death events: attacker = event_var['attacker'] victim = event_var['victim'] event_var['attacker'] = victim event_var['victim'] = attacker return True [/syntax] If the event modifier function returns [i]False[/i], then the event is not triggered at all for Python scripts. Be careful with that ;)

Installation

Download and extract.

Version Notes For beta

Updated on: 2008-07-13 08:02:12 EST by GODJonez (View Zip Contents)
Changed to another method, this time it should actually work.

( Previous Versions )