Functions

From ADRIFT 5 Manual Wiki
Revision as of 13:09, 5 September 2012 by Saabie (Talk | contribs) (CharacterName function description was missing details of its second parameter 'object')

Jump to: navigation, search

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

Many of these functions can automatically be generated by dragging the appropriate item (Location, object or character) from a folder window to the text area that you wish the function to appear in.


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


CharacterDescriptor Function

Returns the full descriptor (including article and prefix) of the character. ADRIFT will need to determine whether the article should be replaced with "the". A "Bad Function" error will occur in Runner if this function is used on a character that does not have a descriptor. If the point of view of the player character is switched to another character which does not have a descriptor then this function will return "me" or "myself", but only if they are unaltered in the descriptor field of the character with the blue icon named "Player".

NB. Available from version 5.0.17.

Syntax

%CharacterDescriptor[key]% 

Parameters

  • key - The key of the character you wish to display the name of.


CharacterName Function

If the character is known (this will depend on the Known property, if it exists), or the character descripter field is blank, this function returns the proper name of a particular character. If the proper name field is blank this function will return "Anonymous". However, if the character is not known and the character descripter field is NOT blank, it will return the character descriptor instead.

For the player character this function will return "I" in first-person mode, "you" in second-person mode, and the proper name in third-person mode (which defaults to "Anonymous" for the default player character).

For other characters it will return 'he', 'she' or 'it' depending on the characters gender. If the word 'object' is added as a second parameter then it will return 'him' or 'her' instead.

For full details of this complex function, see Character Name substitution.

Syntax

%CharacterName%
%CharacterName[key]%
%CharacterName[key, object]% 

Parameters

  • key - The key of the character you wish to display the name of.
  • object - Adding the word 'object' as a second parameter indicates that an objective pronoun such as 'me', 'you', 'him' or 'her' should be used instead of a subjective pronoun.

CharacterProper Function

Returns the proper name of a particular character. For the default player character, and any character with a blank proper name field, it will return "Anonymous".

NB. Available from version 5.0.17.

Syntax

%CharacterProper[key]% 

Parameters

  • key - The key of the character you wish to display the name of.


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

DisplayCharacter Function

Displays the description of a particular character

Syntax

%DisplayCharacter[key]% 

Parameters

  • key - The key of the character you wish to display the description for.


DisplayLocation Function

Displays the description of a particular Location.

If "Display the short location name when viewing descriptions" is selected in the runner options, then the first thing displayed will be the short description of the location. It will be in boldface.

Next will be the long description of the location, possibly modified by alternate descriptions.

Static objects with "Specifically list objects in location description" selected, and dynamic objects, will then be listed. Objects with a specific "When the object is listed in location, display this" description, will be shown after the listed objects. All dynamic objects will be shown after all static objects (5.0.22 and later).

Characters at the location are then listed, those with specific "What to show when the character is at location" descriptions after the list of other characters.

  • This function does not currently show characters or objects that are sitting or laying on another object.


Syntax

%DisplayLocation[key]% 

Parameters

  • key - The key of the location you wish to display the description for.


DisplayObject Function

Displays the description of a particular object.

Syntax

%DisplayObject[key]% 

Parameters

  • key - The key of the object you wish to display the description for.


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.


ListCharactersIn Function

Lists all the characters inside a particular object.

Syntax

%ListCharactersIn[key]% 

Parameters

  • key - The key of the object you wish to list the characters that are inside of.


ListCharactersOn Function

Lists all the characters sitting, laying or standing on top of a particular object. Example output: "Harry, Fred and George"

Syntax

%ListCharactersOn[key]% 

Parameters

  • key - The key of the object you wish to list the characters that are on top of.


ListCharactersOnAndIn Function

Lists all the characters on and inside a particular object. This is basically the same as ListCharactersOn and ListCharactersIn, but it also formats the output into a complete sentence. Example output: "Harry and fred are on the box, and George are inside the box"

Syntax

%ListCharactersOnAndIn[key]% 

Parameters

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


ListHeld Function

Lists all the objects held by a particular character.

Syntax

%ListHeld[key]% 

Parameters

  • key - The key of the character you wish to list the held objects of.


ListExits Function

Lists all the exits available to a particular character.

Syntax

%ListExits[key]% 

Parameters

  • key - The key of the character you wish to list the exits for.


ListObjectsAtLocation Function

Displays a list of all the objects at a particular location. This will include dynamic objects directly at the location (i.e. not inside or on another object) and static objects which have been marked as explicitly list.

Syntax

%ListObjectsAtLocation[key]% 

Parameters

  • key - The key of the location you wish to list the objects at.


ListWorn Function

Lists all the objects worn by a particular character.

Syntax

%ListWorn[key]% 

Parameters

  • key - The key of the character you wish to list the worn objects of.


ListObjectsIn Function

Lists all the objects inside of a particular container object.

Syntax

%ListObjectsIn[key]% 

Parameters

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


ListObjectsOn Function

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 that are on.


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.


LocationName Function

Returns the short description of a particular Location.

Syntax

%LocationName[key]% 

Parameters

  • key - The key of the location you wish to return the short description for.


LocationOf Function

Returns the key of the location of a particular character.

Syntax

%LocationOf[key]% 

Parameters

  • key - The key of the character you wish to find the location of.


NumberAsText Function

Returns a number written out as text.

Syntax

%NumberAsText[number]% 

Parameters

  • number - Any non-negative integer value


ParentOf Function

Returns the parent key of an object. So for example, if an object is inside another object, or an object is part of a character, the function will return the key of the container object or character. If the function returns more than one parent (for example, the key supplied is a multiple object reference), the keys will be listed in a pipe separated list.

Syntax

%ParentOf[key]%

Parameters

  • key - The key of the object you wish to find the parent of. This can also be a reference, for example %objects%.


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


PropertyValue Function

Returns the current value of a property of an object, Location or character.

Syntax

%PropertyValue[key, propertykey]% 

Parameters

  • key - The key of the location, object or character you wish to obtain the property value of.
  • propertykey - The key of the property you wish to obtain the value of.


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.


TheObject/TheObjects Function

These two functions are identical. However, they are interchangeable to facilitate clearer readability, depending on your task output. These functions will display the full name of an object, replacing any indefinite articles with definite ones, i.e. the word “the”. If the function returns more than one object (for example, the key supplied is a multiple object reference), the objects will be listed in a comma separated list.

Syntax

%TheObject[key]% 

Parameters

  • key - The key of the object you wish. This can also be a reference, for example %objects%.


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.