The place to discuss the ADRIFT Interactive Fiction toolkit

Making Descriptions that Vary (2 min)

A library of video tutorials for ADRIFT 5.0.

Making Descriptions that Vary (2 min)

Postby ElliotM » Thu Mar 24, 2016 12:37 am

Let's say you need to describe something that changes. For example, if you had a traffic object that varies to simulate moving traffic, you can use the One Of expression by putting the following into your traffic object's description textbox:
adrift Code: Select all
You see a <# OneOf("yellow","blue","red","green") #> car drive by.

The One Of expression will randomly choose one of these four colors to use in this description. One Of doesn't require a variable but you won't be able to refer to the chosen value later you could with a variable.

An alternative would be to set a color variable equal to the One Of expression in a task action:
adrift Code: Select all
Set variable 'color' to OneOf("yellow","blue","red","green")

This will allow us to use the chosen color later and keep that value until we decide to change it. To make use of that variable in text, you put the following in the description of the taxi object:
adrift Code: Select all
A %color% taxi is waiting here.

While the traffic color will vary each time we see its description, the taxi color will remain consistent until we update it with a task action.

Random Color.taf
Demonstrates using the OneOf expression to vary object descriptions each time they are seen. Also shows how to store the output of OneOf so it can be reused until you decide to update it with a task.
(15.45 KiB) Downloaded 250 times
Posts: 1227
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA
Points: 13

Return to Video Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest