Scripting:TWBaseTrap: Difference between revisions

Building pieces of another world.
Jump to navigation Jump to search
gravatar The Watcher [userbureaucratsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs)
No edit summary
gravatar The Watcher [userbureaucratsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs)
No edit summary
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:


Note: standard Trap Control Flags property is not used or supported.
Note: standard Trap Control Flags property is not used or supported.
== Messages ==


; <code>[ScriptName]On</code>
; <code>[ScriptName]On</code>
: Type: [[Scripting:Design_Note#string|string]]
: '''Type''': [[Scripting:Design_Note#string|string]]
: Use this parameter to specify which script message should activate the script. The default is TurnOn.
: '''Default''': <code>TurnOn</code>
: Use this parameter to specify which script message should activate the script.


; <code>[ScriptName]Off</code>
; <code>[ScriptName]Off</code>
: Type: [[Scripting:Design_Note#string|string]]
: '''Type''': [[Scripting:Design_Note#string|string]]
: Use this parameter to specify which script message should deactivate the script. The default is TurnOff.
: '''Default''': <code>TurnOff</code>
: Use this parameter to specify which script message should deactivate the script.


You can use <code>[ScriptName]On="TurnOff"; [ScriptName]Off="TurnOn"</code> to simulate the Invert Trap Control Flag; <code>[ScriptName]On="Null"</code> can be used to simulate NoOn and <code>[ScriptName]Off="Null"</code> can be used to simulate NoOff.
You can use <code>[ScriptName]On="TurnOff"; [ScriptName]Off="TurnOn"</code> to simulate the Invert Trap Control Flag; <code>[ScriptName]On="Null"</code> can be used to simulate NoOn and <code>[ScriptName]Off="Null"</code> can be used to simulate NoOff.
== Use limiting ==


; <code>[ScriptName]Count</code>
; <code>[ScriptName]Count</code>
: Type: [[Scripting:Design_Note#int|integer]]
: '''Type''': [[Scripting:Design_Note#int|integer]]
: Set the maximum number of times that the script will work. You can use <code>[ScriptName]Count=1</code> to emulate the Once Trap Control Flag. The default is 0 (infinite). Sending the trap a ResetCount message will reset the counter.
: '''Default''': <code>0</code> (infinite)
: Set the maximum number of times that the script will work. You can use <code>[ScriptName]Count=1</code> to emulate the Once Trap Control Flag. Sending the trap a ResetCount message will reset the counter.


; <code>[ScriptName]CountFalloff</code>
; <code>[ScriptName]CountFalloff</code>
: Type: [[Scripting:Design_Note#time|time]]
: '''Type''': [[Scripting:Design_Note#time|time]]
: '''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 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 <code>[ScriptName]CountLimit</code> 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 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 <code>[ScriptName]CountLimit</code> is true, activations will increase the count of number of times the trap has worked, even if it has had no effect.


; <code>[ScriptName]CountLimit</code>
; <code>[ScriptName]CountLimit</code>
: Type: [[Scripting:Design_Note#bool|boolean]]
: '''Type''': [[Scripting:Design_Note#bool|boolean]]
: '''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]]
: Valid values: <code>1</code>, <code>2</code>, <code>3</code>, <code>On</code>, <code>Off</code>, <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>  
: Both <code>TurnOn</code> and <code>TurnOff</code> are counted against the <code>[ScriptName]Count</code> by default. You can use <code>[ScriptName]CountOnly=1</code> or <code>[ScriptName]CountOnly=On</code> to ignore <code>TurnOff</code>, and <code>[ScriptName]CountOnly=2</code> or <code>[ScriptName]CountOnly=Off</code> to ignore <code>TurnOn</code>.  
: Both <code>TurnOn</code> and <code>TurnOff</code> are counted against the <code>[ScriptName]Count</code> by default. You can use <code>[ScriptName]CountOnly=1</code> or <code>[ScriptName]CountOnly=On</code> to ignore <code>TurnOff</code>, and <code>[ScriptName]CountOnly=2</code> or <code>[ScriptName]CountOnly=Off</code> to ignore <code>TurnOn</code>.  
== Capacitors ==


; <code>[ScriptName][On/Off]Capacitor</code>
; <code>[ScriptName][On/Off]Capacitor</code>
: Type: [[Scripting:Design_Note#int|integer]]
: '''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)
: '''Default''': <code>1</code> (activates 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.  


; <code>[ScriptName][On/Off]CapacitorFalloff</code>
; <code>[ScriptName][On/Off]CapacitorFalloff</code>
: Type: [[Scripting:Design_Note#time|time]]
: '''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)
: '''Default''': <code>0</code> (no falloff)
: 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.


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 <code>[ScriptName]Capacitor</code> and <code>[ScriptName]OnCapacitor</code> or <code>[ScriptName]OffCapacitor</code> at the same time, I'm not entirely sure why you'd want to in most cases.


{{Scripting:Navbox}}
{{Scripting:Navbox}}
{{:Site Navigation}}
{{:Site Navigation}}
<references />
<references />

Latest revision as of 22:51, 21 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.

Messages

[ScriptName]On
Type: string
Default: TurnOn
Use this parameter to specify which script message should activate the script.
[ScriptName]Off
Type: string
Default: TurnOff
Use this parameter to specify which script message should deactivate the script.

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.

Use limiting

[ScriptName]Count
Type: integer
Default: 0 (infinite)
Set the maximum number of times that the script will work. You can use [ScriptName]Count=1 to emulate the Once Trap Control Flag. Sending the trap a ResetCount message will reset the counter.
[ScriptName]CountFalloff
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 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
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
Both TurnOn and TurnOff are counted against the [ScriptName]Count by default. You can use [ScriptName]CountOnly=1 or [ScriptName]CountOnly=On to ignore TurnOff, and [ScriptName]CountOnly=2 or [ScriptName]CountOnly=Off to ignore TurnOn.

Capacitors

[ScriptName][On/Off]Capacitor
Type: integer
Default: 1 (activates 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 [ScriptName]Capacitor=3 will only activate on every third message, while one with [ScriptName]OnCapacitor=4; [ScriptName]OffCapacitor=2 will activate on every second TurnOff message but only every fourth TurnOn message.
[ScriptName][On/Off]CapacitorFalloff
Type: time
Default: 0 (no falloff)
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.

Note that, while you can specify [ScriptName]Capacitor and [ScriptName]OnCapacitor or [ScriptName]OffCapacitor at the same time, I'm not entirely sure why you'd want to in most cases.


Authors

  • gravatar The Watcher [userbureaucratsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+]