Variables

From ADRIFT 5 Manual Wiki
Jump to: navigation, search
THE MAIN ITEMS
Locations
Objects
Tasks
Characters
Events
Variables
Groups
Properties
Text Overrides
Hints
Synonyms
User functions

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' and 'MaxScore' 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.

IconWarning.png Only ever add a simple constant to Score in an action, eg. "Increase Score by 12".

If you want a different scoring system than this then create your own variable and use that for scoring, not %Score%.
  •  %MaxScore% - If this is not zero, then when the game finishes ADRIFT will display the message "In that game you scored %Score% out of a possible %MaxScore%, in %Turns% turns."
Never alter the MaxScore variable, it is set automaticaly to the sum of all of the constants that are added to the %Score% variable in the entire game.
  •  %Turns% - The number of turns elapsed for the game. This can be further increased using a "Time" action.
  •  %Version% - Returns the version of the current Runner executable. Version 5.0.26 is returned as integer 5026.

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.


<<< EventsMain_PageGroups >>>