Random Responses
There are two main ways you can display random text in ADRIFT. You can either use an embedded expression, or an array.
Using Expressions
The easiest way to create a random response is to use an embedded expression.
In any text box, you can embed an expression by placing it between two special tags, <# and #>.
The most useful functions we can use for random text are the Either function, or the OneOf function.
So for example, we can have just part of our response random, like so:
Or we could make the entire text returned random, like so:
Using Arrays
Another way of returning a random response is to use an array.
This is not quite so straightforward, but if you have a lot of responses it can be a little bit cleaner. It also allows you to use the same responses in multiple places in your game.
Firstly, create a text variable, and select the Variable is an Array checkbox.
Enter each individual response on a separate line in the Initial Values box. You do not need to set the length, as this will be automatically calculated as you enter the values.
To obtain an individual value from an array, we need to specify the index from the array that we wish to access. We could do this by creating a variable but we would then have to have a task action set the variable to a random value. Again, the easiest way to do this is to just use an expression, like so:
This will select one of the 14 entries from the array at random.
Array arguments are evaluated as Expressions, and so we do not need to embed them here, keeping the variable call simple. |