User functions

From ADRIFT 5 Manual Wiki
Revision as of 06:30, 23 August 2013 by Saabie (Talk | contribs) (Creating a User Function)

Jump to: navigation, search

These are functions which you create yourself. You can specify any number of parameters to be used in the function call, and these can be any combination of object references, character references, location references, numbers or text. A text box is used to provide the text that is output by the function, and this can contain other functions and embedded expressions to calculate and format the desired output. If the output of the function needs to change depending on restrictions then you can create Alternate Descriptions for full control over the output text.

Creating a User Function

A user function can be created by right-clicking on a folder and choosing "Add New" and "User Function", or by pressing the IconUserFunc.jpg"User Function" button on the main toolbar ribbon (When not in simple mode).

UserAllHeld.jpg

In this example we have created a user function called "AllHeld", which has no parameters and will output the result of the "%Player%.Held(True).Count" item function.

This function can then be used as a shorter way of printing out the number of objects that the player is currently carrying.

Using a user function in text or an expression

The new function we created above can now be used in a text box or expression by placing a "%" (percent) symbol before and after it, just like you would with General Functions or variables.

You are currently carrying %AllHeld[]% objects.

When the above line is printed ADRIFT will execute your user function which contains the Player%.Held(True).Count item function.

If the player is carrying twelve objects then it will print:

You are currently carrying %AllHeld[]% objects.

Adding Parameters

Re-writing ADRIFT messages in a different language

As well as providing a way to perform complex formatting and calculate values in the middle of a block of text, user functions may in future be used to provide many of the messages which are currently output directly by the ADRIFT runner. This will not only allow you to change messages in ways that can't be done with a simple text override, it will allow ADRIFT games to be written in other languages.


<<< General FunctionsMain PageExpressions >>>