The Limits

At the time of writing, DragonSpeak variables can handle numbers ranging from -32768 to +32767. If you try to execute an operation that would throw these numbers out of range, the result may be unexpected.

For example, if you add 1 to +32767, it would roll over to -32768. Conversely, if you subtract 1 from -32768, it would roll over to +32767. Think of it as a number wheel with values -32768 to +32767.

As stated earlier, variables are named and identified by the percent sign (%) in front of a word. The names are case sensitive, and allows character A-z, 0-9, and underscores.

You are allowed up to 500 numerical variables, and each variable can hold two integers (for map coordinates). That gives a total of 1000 integers that could be stored into variables.

By default, unless the variable is being used for coordinates, or being copied, it will always behave as though the .x value is being referenced unless specified. How do we access the second integer? We add a .y to the end of the variable being used.

These two lines do the same thing:

  (5:300) set variable %test to the value 2.
(5:300) set variable %test.x to the value 2.

To use the other half of the variable, simply set the .y coordinate to a value:

  (5:300) set variable %test.y to the value 4.

You can manually set both values in the variable by using this line as well:

  (5:384) set variable %test to the x,y position (2,4).

If variable %test was treated as a coordinate, it would be recognized as position (2,4) on the map. Coordinates aren’t the only way to utilize this, but it is the most basic.

When emitting coordinate variables, it’s important to append the .x and .y modifiers, or you’ll only see the x coordinate returned.

For example, if you use this emit without the .x and .y:

  (5:200) emit message {You are at position %test} to the triggering player.

[♦] You are at position 2

It's not a coordinate -- only half of one. You get the x value alone.

If you instead use:

  (5:200) emit message {You are at position %test.x, %test.y} to the triggering player. 
[♦] You are at position 2, 4

It’s also worth noting that variables can be preceded by characters, but cannot be followed by any additional characters except for .x or .y (i.e: you cannot append characters immediately following a variable). For example:

A valid variable reference:

  (5:632) forget the PhoenixSpeak info {button%buttonNum} about this Dream.

This is valid because the variable name %buttonNum is still being recognized properly by the DS parser. The word ‘button’ does not affect the variable name at all.

An invalid variable reference:

  (5:632) forget the PhoenixSpeak info {%buttonNumbutton} about this Dream.

This is invalid because the parser will try to read %buttonNumbutton as a variable instead of just %buttonNum.

Note: This limitation is not true of strings, which are able to be immediately preceded or followed by characters, as long as any character following the string is not valid as part of a string name (e.g: !, @, #, $, ^, &, *, (, ), <, >, etc.).

For example, if you used ~PlayerName as a string and insert it anywhere in DS that takes text input, you can add characters before or after the string name and the parser will still recognize it properly. In other words, DS will still recognize Hello!~PlayerName and ~PlayerName! as just ~PlayerName by the parser.

Account E-Mail

Password