Custom Context
A custom context is created when the core object is compelled to trigger an event with trigger_event. Data items supplied to trigger_event are added to the custom context, which is then sent to any script listening for the event being triggered.
The receiving script should then be able to interrogate the custom context it receives as if it were a context issued from the game code.
No script outside of trigger_event should need to create a custom context, but it's documented here in order to list the data types it supports.
| Loaded in Campaign |
|
| Loaded in Battle |
|
| Loaded in Frontend |
|
-
custom_context:new() -
Creates a custom context object.
Returns:
custom_context
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 25
-
custom_context:add_data(objectcontext data) -
Adds data to the custom context object. Supported data types:
- boolean: will be accessible to the receiving script as
context.bool - string: will be accessible to the receiving script as
context.string. - number: will be accessible to the receiving script as
context.number. - component: will be accessible to the receiving script using
<context>.component. - table: will be accessible to the receiving script using
custom_context:table_data. - region: will be accessible to the receiving script using
custom_context:region. - character: will be accessible to the receiving script using
custom_context:character. A second character, if added, is accessible to the receiving script usingcustom_context:target_character. - faction: will be accessible to the receiving script using
custom_context:faction. - military_force: will be accessible to the receiving script using
custom_context:military_force. - pending_battle: will be accessible to the receiving script using
custom_context:pending_battle. - garrison_residence: will be accessible to the receiving script using
custom_context:garrison_residence. - building: will be accessible to the receiving script using
custom_context:building. - vector: will be accessible to the receiving script using
custom_context:vector. nil
A limitation of the implementation is that only one object of each type may be placed on the custom context (except for characters, currently).Parameters:
1
objectData object to add
Returns:
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 38
- boolean: will be accessible to the receiving script as
-
custom_context:add_data_with_key(valuevalue,function namestring) -
Adds data to the custom context which will be made accessible at the supplied function name. The function name is supplied by string key.
Parameters:
1
valueValue to add to custom context. Any value may be supplied.
2
Name of function at which the value may be retrieved, if called on the custom context.
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 97
-
custom_context:table_data() -
Called by the receiving script to retrieve the table placed on the custom context, were one specified by the script that created it.
Returns:
tableof user defined values
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 114
-
custom_context:region() -
Called by the receiving script to retrieve the region object placed on the custom context, were one specified by the script that created it.
Returns:
regionregion object
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 122
-
custom_context:character() -
Called by the receiving script to retrieve the character object placed on the custom context, were one specified by the script that created it.
Returns:
charactercharacter object
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 130
-
custom_context:target_character() -
Called by the receiving script to retrieve the target character object placed on the custom context, were one specified by the script that created it. The target character is the second character added to the context.
Returns:
charactertarget character object
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 138
-
custom_context:faction() -
Called by the receiving script to retrieve the faction object placed on the custom context, were one specified by the script that created it.
Returns:
factionfaction object
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 146
-
custom_context:military_force() -
Called by the receiving script to retrieve the military force object placed on the custom context, were one specified by the script that created it.
Returns:
military_forcemilitary force object
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 154
-
custom_context:pending_battle() -
Called by the receiving script to retrieve the pending battle object placed on the custom context, were one specified by the script that created it.
Returns:
pending_battlepending battle object
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 162
-
custom_context:garrison_residence() -
Called by the receiving script to retrieve the garrison residence object placed on the custom context, were one specified by the script that created it.
Returns:
garrison_residencegarrison residence object
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 170
-
custom_context:building() -
Called by the receiving script to retrieve the building object placed on the custom context, were one specified by the script that created it.
Returns:
buildingbuilding object
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 178
-
custom_context:vector() -
Called by the receiving script to retrieve the vector object placed on the custom context, were one specified by the script that created it.
Returns:
vectorvector object
defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 186