Difference between revisions of "Variables"

From ADRIFT 5 Manual Wiki
Jump to: navigation, search
m (Using Text Arrays)
m
Line 38: Line 38:
 
%my_text_array[%my_variable%]% ==> Uses an integer variable to select which text string to display.
 
%my_text_array[%my_variable%]% ==> Uses an integer variable to select which text string to display.
  
* Each array element ends where the Enter key was pressed, however multiple-line text can be output from a text array by using the html (line break) markup code where you want a new line to start.  
+
* Each array element ends where the Enter key was pressed, however multiple-line text can be output from a text array by using the html "br" line break markup code where you want a new line to start.  
  
 
[[File:TextArrayVariable.jpg]]
 
[[File:TextArrayVariable.jpg]]
 
   
 
   
will be displayed as:
+
The array element shown above will be displayed as:
 
  You don't say? That is a neat trick.
 
  You don't say? That is a neat trick.
 
  Tossing the sharp blades into the air once more.   
 
  Tossing the sharp blades into the air once more.   

Revision as of 08:19, 20 November 2011

There are two types of variables in ADRIFT. These are Numeric (Integer) and Text. Both variable types can also be created as arrays (a set of variable values which can be accessed by a unique index starting from 1).

Variables can be compared with other values in Restrictions, and altered using Actions.

Properties and references can also be used in a similar way to variables.

System Variables

Certain variable names have been reserved for System variables. These can be used in any text box to display the indicated value. Of these only 'Score' can be written to, the others are read-only.

  •  %Score% - This variable is where you keep track of the players score in the game. It can be altered using Actions or used in Restrictions. It has a hidden 'run once' functionality built in to it which prevents a particular task from incrementing its value more than once.
  •  %Turns% - The number of turns elapsed for the game.
  •  %Version% - Returns the version of the current Runner executable.

Note: It is currently not possible to test Turns or Version in a restriction.(version 5.00.21)

Displaying Variables

Variables can be displayed in any output text with the following syntax.

Your text here %variable% more text here.

For example, let's say you have a variable that tracks the number of some visible object. If it can change throughout the game, you can use a variable in the description of a room or whatever else to reflect that number.

You see %numberOfDucks% ducks.
You see 4 ducks.

You can also specify for integer values to be displayed as words:

You see %NumberAsText[%numberOfDucks%]% ducks.
You see four ducks.

Using Text Arrays

A text array can be used in an expression or directly in a text box to vary the text that is displayed to the player.

Examples:

%my_text_array[RAND(1,10)]% ==> Randomly outputs one of 10 different text strings.

%my_text_array[3]% ==> Outputs the third text string in the array.

%my_text_array[%my_variable%]% ==> Uses an integer variable to select which text string to display.

  • Each array element ends where the Enter key was pressed, however multiple-line text can be output from a text array by using the html "br" line break markup code where you want a new line to start.

TextArrayVariable.jpg

The array element shown above will be displayed as:

You don't say? That is a neat trick.
Tossing the sharp blades into the air once more.  
  • A text array can contain a maximum of 32,767 characters total.
  • The 32,767 characters can all be in one element or divided amongst several.
  • Each additional element counts as 2 extra characters in addition to the visible characters, so a maximum of 10,923 array elements can be created if each contains one character.