Difference between revisions of "General Functions"

From ADRIFT 5 Manual Wiki
Jump to: navigation, search
m
(ListObjectsOnAndIn unobsoleted)
Line 39: Line 39:
 
'''Parameters'''
 
'''Parameters'''
 
* ''string'' - The text string you wish to convert to lower case.  
 
* ''string'' - The text string you wish to convert to lower case.  
 +
 +
 +
== ListObjectsOnAndIn Function ==
 +
Lists all the [[objects]] on and inside a particular object.  This is basically the same as ListObjectsOn and ListObjectsIn, but it gives the response in a nicer syntax when there are objects both on and in the object.
 +
 +
'''Syntax'''
 +
%ListObjectsOnAndIn[key]%
 +
'''Parameters'''
 +
* ''key'' - The [[key]] of the object you wish to list the objects that are on and in.
 +
Note that the item function %object%.Children(Objects).List will simply list all of the objects on and in the object, whereas this function prints something like "A plastic cup is on the cabinet, and inside is a gold coin"
  
  

Revision as of 07:44, 4 March 2013

There are quite a few general functions that can be added to any text within ADRIFT 5. These functions must always be within percent (%) symbols. Any arguments must be provided in square brackets. If multiple arguments are required, these should be separated by comma's.

The general functions which were previously used to access item properties now have equivalent Item functions which are easier to use and offer extra functionality. Their descriptions can be found on the Obsolete general functions page. The obsolete functions are: CharacterDescriptor, CharacterName, CharacterProper, DisplayCharacter, DisplayLocation, DisplayObject, ListCharactersIn, ListCharactersOn, ListCharactersOnAndIn, ListHeld, ListExits, ListObjectsAtLocation, ListObjectsOn, ListObjectsIn, ListObjectsOnAndIn, ListWorn, LocationName, LocationOf, ParentOf, PropertyValue, TheObject.


AloneWithChar Function

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 Function

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 Function

Returns a string that has been converted to lower case.

Syntax

%LCase[string]% 

Parameters

  • string - The text string you wish to convert to lower case.


ListObjectsOnAndIn Function

Lists all the objects on and inside a particular object. This is basically the same as ListObjectsOn and ListObjectsIn, but it gives the response in a nicer syntax when there are objects both on and in the object.

Syntax

%ListObjectsOnAndIn[key]% 

Parameters

  • key - The key of the object you wish to list the objects that are on and in.

Note that the item function %object%.Children(Objects).List will simply list all of the objects on and in the object, whereas this function prints something like "A plastic cup is on the cabinet, and inside is a gold coin"


NumberAsText Function

Returns a number written out as text.

Syntax

%NumberAsText[number]% 

Parameters

  • number - Any non-negative integer value


PCase Function

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[string]% 

Parameters

  • string - The text string you wish to convert to proper case.


Player Function

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 popup 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 directly in a restriction. If you need to do this then call PopupChoice in an action which stores result in a variable and then execute a system task (with another action) which checks the 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 popup 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.

  • Do NOT use 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 the variable with a restriction.

Syntax

%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.

ActionEnterYourName.jpg


Rand Function

The Rand function returns a random value between two integers.

Syntax

RAND(value1, value2)

Parameters

  • value1 - The lowest possible value you wish the function to return.
  • value2 - The highest possible value you wish the function to return.


UCase Function

Returns a string that has been converted to upper case

Syntax

%UCase[string]% 

Parameters

  • string - The text string you wish to convert to upper case.


<<< List of Item functionsMain PageObsolete general functions >>>