Scripting:Design Note: 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 |
||
(One intermediate revision by the same user not shown) | |||
Line 13: | Line 13: | ||
The value you can specify for any given parameter depends on its ''type''. The documentation for each parameter says what type of value it expects you to give it, and it may require any of the following: | The value you can specify for any given parameter depends on its ''type''. The documentation for each parameter says what type of value it expects you to give it, and it may require any of the following: | ||
; <code>float</code> | ; <code id="float">float</code> | ||
: the value should be a real number, that is a number that can include a fractional part, like <code>3.1415</code>. Negative numbers are specified using <code>-</code>, eg: <code>-2.54</code>. Note that, in some cases, negatives can produce unexpected or undesirable behaviours if the script doesn't expect you to use them. | : the value should be a real number, that is a number that can include a fractional part, like <code>3.1415</code>. Negative numbers are specified using <code>-</code>, eg: <code>-2.54</code>. Note that, in some cases, negatives can produce unexpected or undesirable behaviours if the script doesn't expect you to use them. | ||
; <code>float vector</code> | ; <code id="floatvec">float vector</code> | ||
: three <code>float</code> values, separated by commas. You may place whitespace between the <code>float</code> values and the commas, but '''do not''' use quotes around each value, ie: <code>SomeParam=0 , 1.2, 5;</code> is fine, as is <code>SomeParam="1.2, 3.4,5.6";</code>, but <code>SomeParam="0","1.2","3";</code> '''is not''' valid. I generally recommend avoid using quotes when specifying the values for <code>float vector</code> types. Unless otherwise indicated in the documentation, the first value corresponds to the <code>x</code> component of the vector, the second to the <code>y</code> component, and the third to the <code>z</code>. Any components you do not specify a value for will be set to <code>0.0</code>. For example, the value <code>6,,10.5</code> will set <code>x</code> to <code>6.0</code>, <code>y</code> to <code>0.0</code>, and <code>z</code> to <code>10.5</code>. Similarly, <code>1,0.5</code> will set <code>x</code> to <code>1.0</code>, <code>y</code> to <code>0.5</code>, and <code>z</code> (which has been omitted entirely from the example here!) will be set to <code>0.0</code>. | : three <code>float</code> values, separated by commas. You may place whitespace between the <code>float</code> values and the commas, but '''do not''' use quotes around each value, ie: <code>SomeParam=0 , 1.2, 5;</code> is fine, as is <code>SomeParam="1.2, 3.4,5.6";</code>, but <code>SomeParam="0","1.2","3";</code> '''is not''' valid. I generally recommend avoid using quotes when specifying the values for <code>float vector</code> types. Unless otherwise indicated in the documentation, the first value corresponds to the <code>x</code> component of the vector, the second to the <code>y</code> component, and the third to the <code>z</code>. Any components you do not specify a value for will be set to <code>0.0</code>. For example, the value <code>6,,10.5</code> will set <code>x</code> to <code>6.0</code>, <code>y</code> to <code>0.0</code>, and <code>z</code> to <code>10.5</code>. Similarly, <code>1,0.5</code> will set <code>x</code> to <code>1.0</code>, <code>y</code> to <code>0.5</code>, and <code>z</code> (which has been omitted entirely from the example here!) will be set to <code>0.0</code>. | ||
; <code>integer</code> | ; <code id="int">integer</code> | ||
: a 'whole number', one without any decimal part, eg: <code>3</code>. Negative numbers can be specified using <code>-</code>, eg: <code>-42</code>. | : a 'whole number', one without any decimal part, eg: <code>3</code>. Negative numbers can be specified using <code>-</code>, eg: <code>-42</code>. | ||
; <code>boolean</code> | ; <code id="bool">boolean</code> | ||
: a true or false value. The following are considered to be 'true' values: Any word starting 't', 'T', 'y' or 'Y'; Any non-zero integer value. Any words that do not start as described, or the number <code>0</code>, are considered to be false. | : a true or false value. The following are considered to be 'true' values: Any word starting 't', 'T', 'y' or 'Y'; Any non-zero integer value. Any words that do not start as described, or the number <code>0</code>, are considered to be false. | ||
; <code>time</code> | ; <code id="time">time</code> | ||
: an | : an value that represents a period of time. Without any modifier, the the value is interpreted as a number of milliseconds, if you append <code>s</code> to the number (eg: <code>10s</code>) the value is interpreted as a number of seconds. If you place <code>m</code> after the number, it is interpreted as a number of minutes. When using <code>s</code> and <code>m</code> you can use decimal values. For example, <code>0.5s</code> is parsed as 500 milliseconds. If using a qvar instead of a literal time value here (see below for more on this), you ''can not'' specify the <code>s</code> or <code>m</code> modifiers: the value in the qvar must be the time in milliseconds. | ||
; <code>object</code> | ; <code id="obj">object</code> | ||
: a Dromed object name, or object ID. | : a Dromed object name, or object ID. | ||
; <code>string</code> | ; <code id="string">string</code> | ||
: any text, no special meaning is attached to it. Note that, if the string needs to contain a semicolon (;) you *must* enclose the string in single or double quotes, <code>'like this'</code> or <code>"like this"</code>. If you need to include a single quote in a single-quoted string, you can do so by prefixing the <code>'</code> with <code>\</code>, ie: <code>\'</code>. Similarly, to include a double quote in a double-quoted string, prefix it with a backslash, <code>\"</code>. If you need to include a backslash in a quoted string, you should generally prefix it with another, eg: <code>\\</code>. | : any text, no special meaning is attached to it. Note that, if the string needs to contain a semicolon (;) you *must* enclose the string in single or double quotes, <code>'like this'</code> or <code>"like this"</code>. If you need to include a single quote in a single-quoted string, you can do so by prefixing the <code>'</code> with <code>\</code>, ie: <code>\'</code>. Similarly, to include a double quote in a double-quoted string, prefix it with a backslash, <code>\"</code>. If you need to include a backslash in a quoted string, you should generally prefix it with another, eg: <code>\\</code>. | ||
; <code>target</code> | ; <code id="target">target</code> | ||
: a string describing how to choose a target object, objects, or links. The syntax that should be used when specifying values of this type is complicated, so for clarity it is described [[Scripting: | : a string describing how to choose a target object, objects, or links. The syntax that should be used when specifying values of this type is complicated, so for clarity it is described [[Scripting:Targeting|on its own page]]. | ||
For the <code>integer</code>, <code>float</code>, <code>boolean</code>, and <code>time</code> types, you may also use a quest variable in place of a literal value. To do this, prepend the quest variable name with <code>$</code>. For example, this will use the value specified in the quest variable <code>platform_speed</code>: | For the <code>integer</code>, <code>float</code>, <code>boolean</code>, and <code>time</code> types, you may also use a quest variable in place of a literal value. To do this, prepend the quest variable name with <code>$</code>. For example, this will use the value specified in the quest variable <code>platform_speed</code>: | ||
Line 60: | Line 60: | ||
<source lang="txt" style="bright">TWTrapSetSpeedSpeed=5;TWTrapSetSpeedDest='*TerrPt'</source> | <source lang="txt" style="bright">TWTrapSetSpeedSpeed=5;TWTrapSetSpeedDest='*TerrPt'</source> | ||
{{Scripting:Navbox}} | {{Scripting:Navbox}} | ||
{{:Site Navigation}} | {{:Site Navigation}} | ||
<references /> | <references /> |
Latest revision as of 16:37, 19 June 2020
The various scripts provided within the TWScript package use the Editor -> Design Note
feature in Dromed to store the configuration information used to control the behaviour of the scripts. If you have used NVScript, tnhScript, or PublicScripts you will be familiar with this mechanism.
For some scripts, the Design Note may be left empty: some scripts may use the values set in other object attributes for configuration, or they may not support any setup at all. However, in practice the Design Note will contain one or more configuration parameters. Each parameter consists of three parts:
- a parameter name, something like
TWTrapSetSpeedDest
- an equals sign (=)
- a value to set for the parameter
For example:
TWTrapSetSpeedDest='SomeTerrPt'
The value you can specify for any given parameter depends on its type. The documentation for each parameter says what type of value it expects you to give it, and it may require any of the following:
float
- the value should be a real number, that is a number that can include a fractional part, like
3.1415
. Negative numbers are specified using-
, eg:-2.54
. Note that, in some cases, negatives can produce unexpected or undesirable behaviours if the script doesn't expect you to use them.
float vector
- three
float
values, separated by commas. You may place whitespace between thefloat
values and the commas, but do not use quotes around each value, ie:SomeParam=0 , 1.2, 5;
is fine, as isSomeParam="1.2, 3.4,5.6";
, butSomeParam="0","1.2","3";
is not valid. I generally recommend avoid using quotes when specifying the values forfloat vector
types. Unless otherwise indicated in the documentation, the first value corresponds to thex
component of the vector, the second to they
component, and the third to thez
. Any components you do not specify a value for will be set to0.0
. For example, the value6,,10.5
will setx
to6.0
,y
to0.0
, andz
to10.5
. Similarly,1,0.5
will setx
to1.0
,y
to0.5
, andz
(which has been omitted entirely from the example here!) will be set to0.0
.
integer
- a 'whole number', one without any decimal part, eg:
3
. Negative numbers can be specified using-
, eg:-42
.
boolean
- a true or false value. The following are considered to be 'true' values: Any word starting 't', 'T', 'y' or 'Y'; Any non-zero integer value. Any words that do not start as described, or the number
0
, are considered to be false.
time
- an value that represents a period of time. Without any modifier, the the value is interpreted as a number of milliseconds, if you append
s
to the number (eg:10s
) the value is interpreted as a number of seconds. If you placem
after the number, it is interpreted as a number of minutes. When usings
andm
you can use decimal values. For example,0.5s
is parsed as 500 milliseconds. If using a qvar instead of a literal time value here (see below for more on this), you can not specify thes
orm
modifiers: the value in the qvar must be the time in milliseconds.
object
- a Dromed object name, or object ID.
string
- any text, no special meaning is attached to it. Note that, if the string needs to contain a semicolon (;) you *must* enclose the string in single or double quotes,
'like this'
or"like this"
. If you need to include a single quote in a single-quoted string, you can do so by prefixing the'
with\
, ie:\'
. Similarly, to include a double quote in a double-quoted string, prefix it with a backslash,\"
. If you need to include a backslash in a quoted string, you should generally prefix it with another, eg:\\
.
target
- a string describing how to choose a target object, objects, or links. The syntax that should be used when specifying values of this type is complicated, so for clarity it is described on its own page.
For the integer
, float
, boolean
, and time
types, you may also use a quest variable in place of a literal value. To do this, prepend the quest variable name with $
. For example, this will use the value specified in the quest variable platform_speed
:
TWTrapSetSpeedSpeed=$platform_speed
In addition, integer
and float
types can have simple mathematical operations included in the parameter value if the parameter starts with a quest variable. eg:
TWTrapSetSpeedSpeed=$platform_speed * $speed_mult
TWTrapSetSpeedSpeed=$platform_speed / 10.0
TWTrapSetSpeedSpeed=$platform_speed + $base_speed
Supported operations are addition +
, multiplication *
, and division /
.
Subtraction is not directly supported, but you can add a negative number for the same effect.
Note that, for float vector
types, each value may be a quest variable:
TWTrapPhysStateCtrlLocation=$thingx, $thingy, $thingz;
Values may be enclosed in quotes, either single quotes or double quotes, but this is not required unless you are specifying a string containing a semicolon, in which case you must quote the string.
If more than one parameter is specified, semicolons are used to separate them, for example:
TWTrapSetSpeedSpeed=5;TWTrapSetSpeedDest='*TerrPt'
|
|