Item Functions

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

Item Functions

Item functions are functions that can be accessed directly on a particular item.  Each function returns an object (usually another item or a group), which in turn might have further functions that can be accessed.  For the more technical people, item functions can be considered Object Oriented functions.


To access the functions available to each object, you must type the dot character (.) directly after the object you wish to access, followed by the function name.  Item functions can be entered directly in any textbox.  ADRIFT recognises an item function by the presence of a dot joining two words with no space between them.  Therefore you don't need to use the % or <# delimiters to separate them from normal text.


For example, "Object2.Name" is a function, whereas "Object2." is simply a key followed by a full stop.


To access the Item functions, the first word must be one of the following:

Item functions are very powerful, as you can return lists that can be refined by multiple properties in order to return exactly what you want.  For example: "%character%.Held.Drinkable.Count" can be used to return the number of drinkable items held by the referenced character.

Intellisense Menus

If you type a reference, item key or function that returns a key, then press the full stop "." key, ADRIFT will display a menu of all the available functions which are applicable to that type of item.  For example:



If you now press the Down arrow key, ADRIFT will show a description of the selected function.


Press Enter, Tab or Space to insert the currently selected function after the ".".  You can also select a function by clicking on it with the mouse.


If the list is very long, you can just start typing the name (or part of the name).  This will automatically reduce the list by everything matching the current function typed so far.


You can close the intellisense menu using the Escape key.


If by chance you want to prevent the intellisense popup, or create text that looks like an item function, just insert an empty html tag in the function, for example "%character%<>." or "Player<>.Held".

Parameters

Some Item functions take optional parameters.  Parameters are additional values that are passed into a function.  If the parameters are not supplied, a default is assumed.


For example, if you want to return the Children from an object, you would type the following OO function:



You can see that the description states that the function can take parameters.  If, instead of typing a space or a full stop, you type an open bracket, you get a further intellisense menu for the function parameters, like so:



You can now see all the possible parameters for this function.  You can supply multiple parameters by separating them with a comma.  From the description above, you can see that "All" is the default.  Therefore the .Children function without any parameters is the same as writing .Children(All).  If you wish to return a different set of children (i.e. just characters on the object, or just objects inside it), you need to select a different parameter (or parameters)from the list.

Function Types

Each different item type will return different functions.


Location functions

These functions return the key of a location.  These would not normally be displayed to the player, but can be used to access properties of the location by adding another dot followed by the name of a property that locations can have.


All locations offer the following functions:


In addition, any location properties will be listed.  These will return the value of the property.


Object functions

These functions return the key of an object


All objects offer the following functions:


In addition, any object properties will be listed.  These will return the value of the property.


Character functions

These functions return the key of a character.


All characters offer the following functions:


In addition, any character properties will be listed.  These will return the value of the property.


Event functions

All events offer the following functions:


List functions

Any function that returns a list will return those keys separated by a pipe symbol "|".  For example, "%Player%.Location.Exits" might output as "North|East|South".  You would typically always use one of the functions below to handle this information.


Lists offer the following functions:


In addition, any numeric properties of the type of list will be listed.  These will be summed.  For example, "%character%.Held.Weight" will return the sum of the weight of all items held by the character in question.


In addition, any selection only properties of the type of list will be listed, for use as group filters (see below).


Some list functions can use parameters to filter the results.  For example the ".Children" group can contain both Objects and Characters, and these can be either on or inside the parent object.  The function ".Children(Objects, On)" will filter the contents of the group to return only those which are objects and that are on top of the parent object.


Group filters

Any selection only property can be used to refine a list, so that only the items with that property selected will remain.  This is effectively a filter on the current list.


For example, the function "%object%.Contents(Characters).Known" will take the list of characters that are inside the given object, and filter them with the "known" property so that only characters inside the object which are known to the player will be in the returned list.


Text functions

These functions simply return text that can be displayed or stored in a text variable.


Integer functions

These functions return a number that can be displayed, stored in an integer variable, or used in an expression.  If the parent function is a list, the values will be summed.