Scripting:TWBaseTrigger: Difference between revisions
The Watcher [PHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs) No edit summary |
The Watcher [PHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs) No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
All the scripts with "Trigger" in their name inherit from this base trigger script and they send messages - usually <code>TurnOn</code> or <code>TurnOff</code> - in response to some kind event in the level. All TWTrigger...whatever... scripts support the following arguments in the <code>Editor -> Design Note</code>. <code>[ScriptName]</code> here is the name of the script as you entered it into the <code>S->Scripts</code> property. | All the scripts with "Trigger" in their name inherit from this base trigger script and they send messages - usually <code>TurnOn</code> or <code>TurnOff</code> - in response to some kind event in the level. All TWTrigger...whatever... scripts support the following arguments in the <code>Editor -> Design Note</code>. <code>[ScriptName]</code> here is the name of the script as you entered it into the <code>S->Scripts</code> property. | ||
== Messages == | |||
; <code>[ScriptName]TOn</code> | ; <code>[ScriptName]TOn</code> | ||
: Type: [[Scripting:Design_Note#string|string]] | : '''Type''': [[Scripting:Design_Note#string|string]] | ||
: Default: <code>TurnOn</code> | : '''Default''': <code>TurnOn</code> | ||
: Use this parameter to specify which script message the trigger should send when activated. | : Use this parameter to specify which script message the trigger should send when activated. | ||
; <code>[ScriptName]TOff</code> | ; <code>[ScriptName]TOff</code> | ||
: Type: [[Scripting:Design_Note#string|string]] | : '''Type''': [[Scripting:Design_Note#string|string]] | ||
: Default: <code>TurnOff</code> | : '''Default''': <code>TurnOff</code> | ||
: Use this parameter to specify which script message the trigger should send when deactivated. | : Use this parameter to specify which script message the trigger should send when deactivated. | ||
The value specified for <code>[ScriptName]TOn</code> and <code>[ScriptName]TOff</code> can either be a message name, or a stimulus. To have the script send a stimulus instead of a message, specify the intensity of the stim in square brackets followed by the stimulus name. For example: <code>[ScriptName]TOn="[5.00]WaterStim"</code>. You may also specify minimum and maximum intensities for the stimulus by including the two values separated by a |. For example: <code>[ScriptName]TOn="[5.00|10.00]WaterStim"</code> will send a WaterStim with a random intensity between 5.00 and 10.00. | The value specified for <code>[ScriptName]TOn</code> and <code>[ScriptName]TOff</code> can either be a message name, or a stimulus. To have the script send a stimulus instead of a message, specify the intensity of the stim in square brackets followed by the stimulus name. For example: <code>[ScriptName]TOn="[5.00]WaterStim"</code>. You may also specify minimum and maximum intensities for the stimulus by including the two values separated by a |. For example: <code>[ScriptName]TOn="[5.00|10.00]WaterStim"</code> will send a WaterStim with a random intensity between 5.00 and 10.00. | ||
; <code>[ScriptName]TDest</code> | |||
: '''Type''': [[Scripting:Design_Note#target|target]] | |||
: '''Default''': <code>&ControlDevice</code> | |||
: Specify the targets that messages should be sent to when the script is activated or deactivated. The default targets all objects linked to the host object by ControlDevice links. The full capabilities of this parameter are discussed on the [[Scripting:Targetting|Targetting]] page. | |||
== Use limiting == | |||
; <code>[ScriptName]TCount</code> | ; <code>[ScriptName]TCount</code> | ||
: Type: [[Scripting:Design_Note#int|integer]] | : '''Type''': [[Scripting:Design_Note#int|integer]] | ||
: Default: <code>0</code> (infinite) | : '''Default''': <code>0</code> (infinite) | ||
: Use this parameter to specify the maximum number of times that the script will work. You can use <code>[ScriptName]TCount=1</code> to emulate the Once Trap Control Flag. Sending the trigger a ResetTriggerCount message will reset the counter. | : Use this parameter to specify the maximum number of times that the script will work. You can use <code>[ScriptName]TCount=1</code> to emulate the Once Trap Control Flag. Sending the trigger a ResetTriggerCount message will reset the counter. | ||
; <code>[ScriptName]TCountFalloff</code> | ; <code>[ScriptName]TCountFalloff</code> | ||
: Type: [[Scripting:Design_Note#time|time]] | : '''Type''': [[Scripting:Design_Note#time|time]] | ||
: Default: <code>0</code> (no falloff) | : '''Default''': <code>0</code> (no falloff) | ||
: Specify a time, in milliseconds, that it takes for the count to decrease by one. This defaults to 0, which means that no falloff happens and the script will stop working when the count is reached until a ResetTriggerCount message is sent to it. If you set a falloff, the count of the number of times the script has worked is decreased over time, eventually dropping back down to zero if no further activations have happened. Note that, unless [ScriptName]TCountLimit is true, activations will increase the count of number of times the trap has worked, even if it has had no effect. | : Specify a time, in milliseconds, that it takes for the count to decrease by one. This defaults to 0, which means that no falloff happens and the script will stop working when the count is reached until a ResetTriggerCount message is sent to it. If you set a falloff, the count of the number of times the script has worked is decreased over time, eventually dropping back down to zero if no further activations have happened. Note that, unless [ScriptName]TCountLimit is true, activations will increase the count of number of times the trap has worked, even if it has had no effect. | ||
; <code>[ScriptName]TCountLimit</code> | ; <code>[ScriptName]TCountLimit</code> | ||
: Type: [[Scripting:Design_Note#bool|boolean]] | : '''Type''': [[Scripting:Design_Note#bool|boolean]] | ||
: Default: <code>false</code> | : '''Default''': <code>false</code> | ||
: If set to true, the count of number of times the script has worked will be limited to the maximum. Otherwise, every ''attempted'' activation will be counted, even if it didn't work. | : If set to true, the count of number of times the script has worked will be limited to the maximum. Otherwise, every ''attempted'' activation will be counted, even if it didn't work. | ||
; <code>[ScriptName]CountOnly</code> | ; <code>[ScriptName]CountOnly</code> | ||
: Type: [[Scripting:Design_Note#int|integer]]/[[Scripting:Design_Note#string|string]] | : '''Type''': [[Scripting:Design_Note#int|integer]]/[[Scripting:Design_Note#string|string]] | ||
: Default: <code>Both</code> | : '''Default''': <code>Both</code> | ||
: Valid values: <code>1</code>, <code>2</code>, <code>3</code>, <code>On</code>, <code>Off</code>, <code>Both</code> | : '''Valid values''': <code>1</code>, <code>2</code>, <code>3</code>, <code>On</code>, <code>Off</code>, <code>Both</code> | ||
: Sending both <code>TurnOn</code> and <code>TurnOff</code> are counted against the <code>[ScriptName]TCount</code> by default. You can use <code>[ScriptName]TCountOnly=1</code> or <code>[ScriptName]TCountOnly=On</code> to ignore <code>TurnOff</code>, and <code>[ScriptName]TCountOnly=2</code> or <code>[ScriptName]TCountOnly=Off</code> to ignore <code>TurnOn</code>. | : Sending both <code>TurnOn</code> and <code>TurnOff</code> are counted against the <code>[ScriptName]TCount</code> by default. You can use <code>[ScriptName]TCountOnly=1</code> or <code>[ScriptName]TCountOnly=On</code> to ignore <code>TurnOff</code>, and <code>[ScriptName]TCountOnly=2</code> or <code>[ScriptName]TCountOnly=Off</code> to ignore <code>TurnOn</code>. | ||
; [ScriptName]FailChance | == Other == | ||
: Type: [[Scripting:Design_Note#int|integer]] | ; <code>[ScriptName]FailChance</code> | ||
: Default: <code>0</code> (always succeeds) | : '''Type''': [[Scripting:Design_Note#int|integer]] | ||
: '''Default''': <code>0</code> (always succeeds) | |||
: Use this parameter to specify a % chance that the trigger will fail (do nothing) when it is activated. For example: <code>[ScriptName]FailChance=35</code> will give the trigger a 35% chance to fail when activated. | |||
{{Scripting:Navbox}} | {{Scripting:Navbox}} | ||
{{:Site Navigation}} | {{:Site Navigation}} | ||
<references /> | <references /> |
Latest revision as of 22:40, 20 June 2020
All the scripts with "Trigger" in their name inherit from this base trigger script and they send messages - usually TurnOn
or TurnOff
- in response to some kind event in the level. All TWTrigger...whatever... scripts support the following arguments in the Editor -> Design Note
. [ScriptName]
here is the name of the script as you entered it into the S->Scripts
property.
Messages
[ScriptName]TOn
- Type: string
- Default:
TurnOn
- Use this parameter to specify which script message the trigger should send when activated.
[ScriptName]TOff
- Type: string
- Default:
TurnOff
- Use this parameter to specify which script message the trigger should send when deactivated.
The value specified for [ScriptName]TOn
and [ScriptName]TOff
can either be a message name, or a stimulus. To have the script send a stimulus instead of a message, specify the intensity of the stim in square brackets followed by the stimulus name. For example: [ScriptName]TOn="[5.00]WaterStim"
. You may also specify minimum and maximum intensities for the stimulus by including the two values separated by a |. For example: [ScriptName]TOn="[5.00|10.00]WaterStim"
will send a WaterStim with a random intensity between 5.00 and 10.00.
[ScriptName]TDest
- Type: target
- Default:
&ControlDevice
- Specify the targets that messages should be sent to when the script is activated or deactivated. The default targets all objects linked to the host object by ControlDevice links. The full capabilities of this parameter are discussed on the Targetting page.
Use limiting
[ScriptName]TCount
- Type: integer
- Default:
0
(infinite) - Use this parameter to specify the maximum number of times that the script will work. You can use
[ScriptName]TCount=1
to emulate the Once Trap Control Flag. Sending the trigger a ResetTriggerCount message will reset the counter.
[ScriptName]TCountFalloff
- Type: time
- Default:
0
(no falloff) - Specify a time, in milliseconds, that it takes for the count to decrease by one. This defaults to 0, which means that no falloff happens and the script will stop working when the count is reached until a ResetTriggerCount message is sent to it. If you set a falloff, the count of the number of times the script has worked is decreased over time, eventually dropping back down to zero if no further activations have happened. Note that, unless [ScriptName]TCountLimit is true, activations will increase the count of number of times the trap has worked, even if it has had no effect.
[ScriptName]TCountLimit
- Type: boolean
- Default:
false
- If set to true, the count of number of times the script has worked will be limited to the maximum. Otherwise, every attempted activation will be counted, even if it didn't work.
[ScriptName]CountOnly
- Type: integer/string
- Default:
Both
- Valid values:
1
,2
,3
,On
,Off
,Both
- Sending both
TurnOn
andTurnOff
are counted against the[ScriptName]TCount
by default. You can use[ScriptName]TCountOnly=1
or[ScriptName]TCountOnly=On
to ignoreTurnOff
, and[ScriptName]TCountOnly=2
or[ScriptName]TCountOnly=Off
to ignoreTurnOn
.
Other
[ScriptName]FailChance
- Type: integer
- Default:
0
(always succeeds) - Use this parameter to specify a % chance that the trigger will fail (do nothing) when it is activated. For example:
[ScriptName]FailChance=35
will give the trigger a 35% chance to fail when activated.
|
|