Call script

From Mount&Blade Modding Wiki
Jump to: navigation, search

call_script is a control operation.

Contents

[edit] Description

When run from a code block, call_script scans the list of scripts (compiled from module_scripts.py) and then processes the script which matches the provided script ID. After all code in the script has been executed, the game resumes processing the original code block. Variables can be provided to call_script as "parameters" (input values to be used by the script); if any "return" values (output values to be used by the original code block) are needed afterward, they are assigned to registers by the script.

The script name parameter should include the "script_" prefix, but scripts in module_scripts.py do not include these prefixes. For instance, to call the script named "find_center_to_defend", you would use the script ID "script_find_center_to_defend".

All script processing in Mount and Blade is "single-threaded". This means that two pieces of code will not run at the same time; in single player, you can be assured that the script called will complete prior to resuming the original script that it was called from. This also means, however, that if the script run by call_script loops infinitely, Mount and Blade will no longer process any additional code until the script is unloaded or until it finally is resolved. This can also result in severe "freezes" in gameplay as the script happily processes away while the game waits for it to finish.

[edit] Syntax

(call_script, script_ID<string>)

(call_script, script_ID<string>, parameter_1<variable>, ..., parameter_n<variable>)
script_ID 
The ID of the script to execute, including "script_" prefix.
parameter_1
...
parameter_n 
(Optional) Zero or more variables of any kind, separated by commas, to be used as the input of the script; the script can get the values of these with the store_script_param operation.

[edit] Example

(call_script, "script_give_center_to_faction_aux", "p_town_1", "fac_kingdom_4"),

—from script_game_start

[edit] See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox