Scripting:TWBaseTrap: 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 |
||
Line 22: | Line 22: | ||
; <code>[ScriptName]CountLimit</code> | ; <code>[ScriptName]CountLimit</code> | ||
: Type: [[Scripting:Design_Note# | : Type: [[Scripting:Design_Note#bool|boolean]] | ||
: 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. | ||
Line 31: | Line 31: | ||
; <code>[ScriptName][On/Off]Capacitor</code> | ; <code>[ScriptName][On/Off]Capacitor</code> | ||
: Type: [[Scripting:Design_Note#int|integer]] | |||
: Use this parameter to specify the number of times that a trap will need to receive its triggering message before it activates. For example, an script with <code>[ScriptName]Capacitor=3</code> will only activate on every third message, while one with <code>[ScriptName]OnCapacitor=4; [ScriptName]OffCapacitor=2</code> will activate on every second <code>TurnOff</code> message but only every fourth <code>TurnOn</code> message. The default is 1 (activate for every message) | : Use this parameter to specify the number of times that a trap will need to receive its triggering message before it activates. For example, an script with <code>[ScriptName]Capacitor=3</code> will only activate on every third message, while one with <code>[ScriptName]OnCapacitor=4; [ScriptName]OffCapacitor=2</code> will activate on every second <code>TurnOff</code> message but only every fourth <code>TurnOn</code> message. The default is 1 (activate for every message) | ||
; <code>[ScriptName][On/Off]CapacitorFalloff</code> can be used to specify the time, in milliseconds, that it takes for the trap to "lose charge", and the activation count to go back down by one activation. Defaults to 0 (no falloff) | ; <code>[ScriptName][On/Off]CapacitorFalloff</code> | ||
: Type: [[Scripting:Design_Note#time|time]] | |||
: can be used to specify the time, in milliseconds, that it takes for the trap to "lose charge", and the activation count to go back down by one activation. Defaults to 0 (no falloff) | |||
Note that, while you ''can'' specify [ScriptName]Capacitor and [ScriptName]OnCapacitor or [ScriptName]OffCapacitor at the same time, you probably don't really want to. | Note that, while you ''can'' specify [ScriptName]Capacitor and [ScriptName]OnCapacitor or [ScriptName]OffCapacitor at the same time, you probably don't really want to. |
Revision as of 16:22, 20 June 2020
All the scripts with "Trap" in their name inherit from this base trap script and they typically do something in response to being sent messages - usually a TurnOn
or TurnOff
message. All TWTrap...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.
Note: standard Trap Control Flags property is not used or supported.
[ScriptName]On
- Type: string
- Use this parameter to specify which script message should activate the script. The default is TurnOn.
[ScriptName]Off
- Type: string
- Use this parameter to specify which script message should deactivate the script. The default is TurnOff.
You can use [ScriptName]On="TurnOff"; [ScriptName]Off="TurnOn"
to simulate the Invert Trap Control Flag; [ScriptName]On="Null"
can be used to simulate NoOn and [ScriptName]Off="Null"
can be used to simulate NoOff.
[ScriptName]Count
- Type: integer
- Set the maximum number of times that the script will work. You can use
[ScriptName]Count=1
to emulate the Once Trap Control Flag. The default is 0 (infinite). Sending the trap a ResetCount message will reset the counter.
[ScriptName]CountFalloff
- Type: time
- 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 when the count is reached, the script will stop working until a ResetCount 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]CountLimit is true, activations will increase the count of number of times the trap has worked, even if it has had no effect.
[ScriptName]CountLimit
- Type: boolean
- 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
- Valid values:
1
,2
,3
,On
,Off
,Both
- Both
TurnOn
andTurnOff
are counted against the [ScriptName]Count by default. You can use [ScriptName]CountOnly=1 or [ScriptName]CountOnly=On to ignoreTurnOff
, and [ScriptName]CountOnly=2 [ScriptName]CountOnly=Off to ignoreTurnOn
.
[ScriptName][On/Off]Capacitor
- Type: integer
- Use this parameter to specify the number of times that a trap will need to receive its triggering message before it activates. For example, an script with
[ScriptName]Capacitor=3
will only activate on every third message, while one with[ScriptName]OnCapacitor=4; [ScriptName]OffCapacitor=2
will activate on every secondTurnOff
message but only every fourthTurnOn
message. The default is 1 (activate for every message)
[ScriptName][On/Off]CapacitorFalloff
- Type: time
- can be used to specify the time, in milliseconds, that it takes for the trap to "lose charge", and the activation count to go back down by one activation. Defaults to 0 (no falloff)
Note that, while you can specify [ScriptName]Capacitor and [ScriptName]OnCapacitor or [ScriptName]OffCapacitor at the same time, you probably don't really want to.
|
|