-
Notifications
You must be signed in to change notification settings - Fork 4
trigger_script
trigger_script is a special entity that can be used to control script code using entities. It has 2 modes: trigger and think. The mode is specified by the keyvalue named 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.
You may optionally specify a script to load (relative to the main script) using a keyvalue named m_iszScriptFile.
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.
In think mode, triggering the entity can change its state. 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 |
In think mode, a given script function is executed every so often.
This function has the following format:
void FunctionName(CBaseEntity@ pTriggerScript)
The entity that is passed in is the trigger_script entity itself.
The time between executions is specified by a keyvalue named m_flThinkDelta.
By default, a trigger_script in think mode starts off, but setting the spawnflag "Start on" will cause it to start on.
trigger_script can only use functions defined in map scripts.