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 Campaign
Loaded in Battle Loaded in Battle
Loaded in Frontend Loaded in Frontend
Back to top

Functionality

custom_context:new()

Creates a custom context object.

Returns:

  1. custom_context

defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 25

custom_context:add_data(object context 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.


    • 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

      object

      Data object to add

      Returns:

      1. nil

      defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 38

custom_context:add_data_with_key(value value, string function name)

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

value

Value to add to custom context. Any value may be supplied.

2

string

Name of function at which the value may be retrieved, if called on the custom context.

Returns:

  1. 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:

  1. table of 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:

  1. region region 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:

  1. character character 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:

  1. character target 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:

  1. faction faction 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:

  1. military_force military 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:

  1. pending_battle pending 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:

  1. garrison_residence garrison 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:

  1. building building 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:

  1. vector vector object

defined in ../../Warhammer/working_data/script/_lib/lib_custom_context.lua, line 186

Last updated 8/23/2024 4:55:15 PM