trigger_script
trigger_script | |
---|---|
Type |
point |
Status |
supported |
This powerful entity allows you to put scripts made with AngelScript language on your map. Before Sven Co-op 5.0 you already were able to create almost anything with existed entities- this entity pushes imagination barrier even further allowing you to open an existing script and use functions.
1 Keyvalues
Script to load : m_iszScriptFile
The name of the script to load in "scripts\maps" directory, e.g. mymap/my_script1
. This can be left empty if the function already exists from scripts specified via map_script
in cfg.
Function to execute when triggered : m_iszScriptFunctionName
Function (declared in the opened script file) to call when trigger_script is triggered. If the function belongs to a namespace, you must use prefix the function name with the namespace name followed by:: e.g. mynamespace::MyFunction
for the keyvalue.
Time between thinks : m_flThinkDelta
If "Mode" is set to 'Think', this is a time delay between script calls.
Mode : m_iMode
Script call mode. 'Trigger' allows to execute script once, 'Think' executes script every (specified in "Time between thinks") time interval.
2 Flags
1 : Start on
Script is activated on start.
3 Scripting
trigger_script has 2 modes: trigger and think. The mode is specified by the keyvalue m_iMode
.
Both modes require you to specify a function name using a keyvalue named m_iszScriptFunctionName
. This is the function name, not including return type or arguments. The function name must be prepended with the namespace that it exists in, if it does.
You may optionally specify a script to load (relative to the main script) using a keyvalue named m_iszScriptFile
.
3.1 Trigger mode
In trigger mode, triggering the entity will execute a given script function. This function has the following format:
void FunctionName(CBaseEntity@ pActivator, CBaseEntity@ pCaller, USE_TYPE useType, float flValue)
This is the exact same format as an entity's Use function. Refer to the entity documentation for more information on the purpose of each argument.
This allows you to execute a script function by triggering this entity.
3.2 Think mode
In think mode, triggering the entity can change its state.
The time between executions is specified by the keyvalue m_flThinkDelta
.
This function has the following format:
void FunctionName(CBaseEntity@ pTriggerScript)
The entity that is passed in is the trigger_script entity itself.
This entity responds to USE_TYPE inputs as follows:
Use Type | Behavior |
---|---|
USE_OFF | Disables think mode |
USE_ON | Enables think mode |
USE_TOGGLE | Toggles think mode |
USE_SET | Ignored |
USE_KILL | Ignored |
By default, a trigger_script in think mode starts off, but setting the spawnflag "Start on" will cause it to start on.