Template:Op script trigger

Script/trigger parameters and results
Many scripts can accept additional parameters, and many triggers have some parameters of their own (as details in header_triggers.py file). You can only pass numeric values as parameters. Since string constants are also Warband objects, you can pass them as well, and you can also pass string or position registers. However you cannot pass quick strings (string defined directly in the code). You can declare your scripts with as many parameters as you wish. Triggers, however, are always called with their predefined parameters. Also the game engine does not support more than 3 parameters per trigger. As the result, some triggers receive extra information which could not be fit into those three parameters in numeric, string or position registers. Some triggers and scripts called from the game engine (those have names starting with "game_") expect you to return some value to the game engine. That value may be either a number or a string and is set by special operations listed below. Scripts called from the Module System, however, typically use registers to store their return data. Note that if you call a script from a trigger, you can still use operations to retrieve trigger's calling parameters, and they will retrieve values that have been passed to the trigger, not values that have been passed to the script.

store_script_param_1 = 21
 * (store_script_param_1, ),
 * Retrieve the value of the first script parameter.

store_script_param_2 = 22
 * (store_script_param_2, ),
 * Retrieve the value of the second script parameter.

store_script_param = 23
 * (store_script_param,, ),
 * Retrieve the value of arbitrary script parameter (generally used when script accepts more than two). Parameters are enumerated starting from 1.

set_result_string = 60
 * (set_result_string, ),
 * Sets the return value of a game_* script, when a string value is expected by game engine.

store_trigger_param_1 = 2071
 * (store_trigger_param_1, ),
 * Retrieve the value of the first trigger parameter. Will retrieve trigger's parameters even when called from inside a script, for as long as that script is running within trigger context.

store_trigger_param_2 = 2072
 * (store_trigger_param_2, ),
 * Retrieve the value of the second trigger parameter. Will retrieve trigger's parameters even when called from inside a script, for as long as that script is running within trigger context.

store_trigger_param_3 = 2073
 * (store_trigger_param_3, ),
 * Retrieve the value of the third trigger parameter. Will retrieve trigger's parameters even when called from inside a script, for as long as that script is running within trigger context.

store_trigger_param = 2070
 * (store_trigger_param,, ),
 * Version 1.153+. Retrieve the value of arbitrary trigger parameter. Parameters are enumerated starting from 1. Will retrieve trigger's parameters even when called from inside a script, for as long as that script is running within trigger context.

get_trigger_object_position = 702
 * (get_trigger_object_position, ),
 * Retrieve the position of an object which caused the trigger to fire (when appropriate).

set_trigger_result = 2075
 * (set_trigger_result, ),
 * Sets the return value of a trigger or game_* script, when an integer value is expected by game engine.

Keyboard and mouse input
The game provides modders with limited ability to control keyboard input and mouse movements. It is also possible to tamper with game keys (i.e. keys bound to specific game actions), including the ability to override game's reaction to those keys. Note that mouse buttons are keys too, and can be detected with the corresponding operations.

Conditional operations
key_is_down = 70
 * (key_is_down, ),
 * Checks if the specified key is clicked in the current frame, ignoring if it was clicked in the previous frame. See header_triggers.py for key code reference.

key_clicked = 71
 * (key_clicked, ),
 * Checks if the specified key is clicked in the current frame and wasn't clicked in the previous frame. See header_triggers.py for key code reference.

game_key_is_down = 72
 * (game_key_is_down, ),
 * Checks if the specified game key is clicked in the current frame, ignoring if it was clicked in the previous frame. See header_triggers.py for game key code reference.

game_key_clicked = 73
 * (game_key_clicked, ),
 * Checks if the specified game key is clicked in the current frame and wasn't clicked in the previous frame. See header_triggers.py for game key code reference.

Generic operations
omit_key_once = 77
 * (omit_key_once, ),
 * Forces the game to ignore default bound action for the specified key on next press. Some keys can't be omited. Open the link to see all keys that can be omited.

clear_omitted_keys = 78
 * (clear_omitted_keys),
 * Clear all omitted keys.

mouse_get_position = 75
 * (mouse_get_position, ),
 * Stores mouse x and y coordinates in the specified position.