General Functions

ADRIFT 5 Help ›› Creating Games ›› Functions ››
Parent Previous Next

General Functions

General Functions can be inserted in any textbox, and will be evaluated before the text is output.  All General Functions must be delimited by percentage (%) symbols.  Parameters to General Functions must be supplied inside square brackets.

AloneWithChar

This returns the key of the character in the same location as the player.


Always use the restriction The Player Character must be alone with any character to check if this function will return a valid result, before using the result of this function in any equation.


This function can be used as the %character% parameter for an Execute Task action.  The executed task will then be applied to the character that is currently in the same location as the player.


Syntax

%AloneWithChar%

Parameters

none





ConvCharacter

This returns the key of the character the player is currently in conversation with.


Always use the restriction The Player Character must be in conversation with any character to check if this function will return a valid result, before using the result of this function in any equation.


This function can be used as the %character% parameter for an Execute Task action.  The executed task will then be applied to the character that the player is currently in conversation with.


Syntax

%ConvCharacter%

Parameters

none




LCase

This returns a text value in lower case.


Syntax

%LCase[text]%

Parameters

text

The text you wish to convert to lower case.


Example

%LCase[TESTING]% = testing



ListObjectsOnAndIn

Lists all the objects on the surface of a particular object.


Syntax

%ListObjectsOn[key]%

Parameters

key

The key of the object you wish to list the objects on.


It should be noted that this function is very similar to the %object%.Children(Objects).List item function.  However, this function will automatically display the "Inside the" or " and on the" parts where applicable, and so there is no direct item function replacement without adding a significant amount of logic.



NumberAsText

Returns a number written out as text.


Syntax

%NumberAsText[number]%

Parameters

number

Any non-negative integer value


Example

%NumberAsText[123]% = One hundred and twenty three



PCase

Returns a string that has been converted to proper case (i.e. the first letter will be capitalised, and all other letters will be converted to lower case).


Syntax

%PCase[text]%

Parameters

text

The text you wish to convert to proper case.


Example

%PCase[TESTING]% = Testing



Player

This function returns the key of the player character.  This will normally always be known at design time, but if you switch characters during the game, it may be necessary.


Syntax

%Player%

Parameters

none





PopUpChoice

Causes an input box to pop up on the screen, displaying a short message prompt and two choices.  The player chooses one of the two options and this becomes the value returned by the function.  This is used in the expression field of a set variable action to allow the player to choose which of two text strings is written to the variable.


See [Ask player to enter their gender when the game starts] for an example.


Do NOT use this function directly in a restriction.  If you need to do this then call PopupChoice in an action which stores the result in a variable and then execute a system task (with another action) which checks that variable with a restriction.


Syntax

%PopUpChoice[prompt, choice1, choice2]%

Parameters

prompt

An expression (typically a quoted string) to display as a message in the inputbox.

choice1

An expression returned in the function if the user selects this option.

choice2

An expression returned in the function if the user selects this option.



PopUpInput

Causes an input box to pop up on the screen, displaying a short message prompt and a single-line text entry field.  The player can accept the default text or enter a new line of text, then press OK.  This could be used to allow the player to enter their own name, which is then used in the game.  If the player presses cancel then this function will return a zero-length string.  This function should be used in the expression field of either a "Variables" action or a "Set Properties" action.


See [Ask player to enter their gender when the game starts] for an example.


Do NOT use this function directly in a restriction.  If you need to do this then call PopUpInput in an action which stores the result in a variable, and then execute a system task (with another action) which checks that variable with a restriction


Syntax

%PopUpInput[prompt]%
%PopUpInput[prompt, default]%

Parameters

prompt

An expression (typically a quoted string) to display as a message in the inputbox.

default

Optional. An expression (typically a quoted string) to display in the text field of the inputbox.


Example

To ask the player for their name at the start of the game we would create a system task set to run "Immediately", and add the following action to use the PopupInput function to ask them to enter it, then write the name they entered to the "Name" property of the player character.





UCase

Returns a string that has been converted to upper case.


Syntax

%UCase[text]%

Parameters

text

The text you wish to convert to upper case.


Example

%PCase[Testing]% = TESTING