ALR Example Contents

Introduction
Simple Text Replacement
Advanced Text Replacement Using Variables: Part I
Advanced Text Replacement Using Variables: Part II
Randomizing Descriptions: Part I
Randomizing Descriptions: Part II
Special Use For Blanks
A Final Word on ALR Use

Introduction

The next few sections describe how to use your newly created ALR file. Primarily, an ALR file is used (1) for simple text replacement, and (2) in conjunction with variables for advanced text replacement. These two methods will be discussed first, followed by some additional advanced uses for the ALR file. Please be sure to read the section How do I associate an ALR file with my adventure? before reviewing this section if you have any questions about importing an ALR file.

Return to Contents

Simple Text Replacement

You should have a blank ALR file opened in NOTEPAD. Enter the following text all on one line (note that there are no spaces around the "|" character):

You are carrying|You are loaded down with

The "|" character can be found on the same key as the backslash "\" character, accessed by using the SHIFT key. Save and close the ALR file. Now run ADRIFT Generator and open your adventure. Import the ALR file you just created, then save and run your adventure. Use the "I" or "Inventory" command and notice that the usual inventory text has been replaced by what you put in your ALR file, "You are loaded down with..."

You can use this type of simple text replacement for any text in your adventure, whether it is default text used in ADRIFT Generator or text which you have written into your adventure. What if, for example, you had several journals in your game with a lot of text describing a particular place. Weeks later you decided that you don't like the name of the place you originally used. Rather than having to look for and change every area in your adventure where the name is located, just put the old name and new name in an ALR file separated by the "|" character and ADRIFT will replace the name for you.

Return to Contents

Advanced Text Replacement Using Variables: Part I

The following section assumes you have a basic knowledge of ADRIFT variables, including how to create variables, how to assign values to variables, how to display variables in text and how to change a variable's value. If you don't have this basic knowledge, please see the Variables Tutorial in this Topic Tutorial System. You should also review Section 3.3 of the main ADRIFT Tutorial, found on the ADRIFT Homepage (www.adrift.org.uk) as a ZIP file in the Downloads section or online in the Links section.

First, open your adventure in ADRIFT Generator and create a variable entitled "BallColor" with an initial value of "1". Now create an object entitled "ball" and place it in a room at the beginning of your adventure. In the description field of the "ball" object, type "This is a small %BallColor% ball" (the percent % symbol is required around the variable). Save your object, then create a task "paint ball" and have it change the value of the variable BallColor to the value "2". Save your adventure.

Now open the ALR file your created in the previous section and add the following two lines:

1|blue
2|red

Save your ALR file, then import it into your adventure. Don't forget to save your adventure again after you import the ALR file, then run your adventure. Go to the room with the ball and pick it up.

Type "look ball" and you should get the description, "This is a small blue ball". Next, type "paint ball" which will run the task to change the BallColor variable to "2". Now, if you type "look ball" you should get a new description, "This is a small red ball".

Here's what happened. First, when you typed "look ball" ADRIFT replaced %BallColor% in the ball's description with the value of the variable BallColor (initially 1). If you had not imported the ALR file, the response would have been, "This is a small 1 ball". But, since you did import your new ALR file, the ALR file told your adventure to replace the "1" with the text "blue", so the result was, "This is a small blue ball". Likewise, when the variable's value change to "2", the ALR file replaced the number "2" with the text "red".

Return to Contents

Advanced Text Replacement Using Variables: Part II

Unfortunately, a problem with the previous example of Advanced Text Replacement is that the ALR file will replace every occurrence of the number "1" with the text "blue". So, if your player picks up 1 gold piece, the inventory will list "blue gold piece". Obviously, this has some serious drawbacks. For this reason, there are three basic rules when using variable values in an ALR file:

(1) Use high numbers with values unlikely to be used anywhere else in the adventure, such as "9991" and "9992" instead of "1" and "2". Remember to also change your initial BallColor value to "9991" instead of "1". The text in the ALR file should then be changed to the following:

9991|blue
9992|red

(2) Use text-number combinations, such as "Color1" instead of just "1". Using this method, the value of the variable BallColor would stay the same, "1". However, you would need to change the description of the "ball" to "This is a small Color%BallColor% ball". Notice that %BallColor% is now preceeded by "Color" (with no space in-between). The text in your ALR should now be changed to:

Color1|blue
Color2|red

(3) Realistically, the first 2 rules could still cause problems in your game. For instance, the player may go to an address "9992 Haunted House Lane" in the adventure, which would be displayed as "blue Haunted House Lane". You may also run into conflicts with the text-number combinations. Therefore, to more effectively limit any conflicts in an adventure, the best rule is to use a combination of text, numbers AND symbols. An example of this in the ALR file would be:

!Color-1|blue
!Color-2|red

Notice the use of the exclamation point (!) in front and the hypen (-) in the middle. Don't forget to change the "ball" description to "This is a small !Color-%BallColor% ball". Not only does this method ensure that conflicts are very unlikely, but it also helps to organize the descriptions in both your adventure and your ALR file. You will appreciate this aspect of it much more as your adventure becomes larger and more complicated.

Return to Contents

Randomizing Descriptions: Part I

In creating an IF adventure, it is important to continually capture your player's attention. This can be done with an intriguing plot, a captivating environment, challenging puzzles and an air of mystery. ALR files help the writer to accomplish many of these things by allowing descriptions to be randomized. Randomized descriptions keep the player on guard and attentive, whereas mundane descriptions displayed over and over again often leave the player in a stupor, stumbling blindly through the adventure.

Random descriptions are created using a combination of variables and the ALR file, similar to the Advanced Text Replacement described in earlier sections of this tutorial. The difference is that the values of the variables are chosen randomly every turn by an event-task combination running in the background. Therefore, when these variables are placed in a description, the description changes every turn. A simple example follows and a more complex example is described in Part II of this section.

When incorporating characters into an IF adventure, a way is generally provided for the player to know when a character enters and leaves the room. ADRIFT Generator is no exception in that it provides a default entrance/exit description for each character. ADRIFT goes even further to provide the writer the ability to change the description for entering and the description for exiting a room. However, the same description will be displayed every time the character enters and exits the room. Pretty soon, the player's eyes skim over this detail because of its redundancy and the player may then miss something important. An ALR file can be used to dramatically change this pattern.

To illustrate, let's look at several important parts:

First, create two variables, one entitled "CharEnter" and one entitled "CharExit" with initial values of "0".

Next, make sure you have a character created in your adventure and set their movements to walk into and out of the room the player starts in at the beginning of the game. The character should repeat this about every two turns. Also check the Show Characters Entering/Exiting Room checkbox. For the enter description, type "!Enter-%CharEnter%" and in the exit description, type "!Exit-%CharExit%".

Now we need to randomize the values of CharEnter and CharExit every turn. To do this, first create a Task labeled "!Randomize Variables Every Turn". Make sure the Task is repeatable and then add two actions: one to Change the variable "CharEnter" by a random value between "0" and "8" and another one to do the same for the "CharExit" variable. Now every time this task is run, the two variables will be randomly assigned a value between 0 and 8. But, to make the Task run every turn we need an Event to execute it.

Therefore, create an Event labeled "Run Randomization Task Every Turn". The Event should start "Immediately" and should last between "1" and "1" turns. Make sure the checkbox for "Restart this event as soon as it finishes" is checked. Next have the Event execute the "!Randomize Variables Every Turn" task. Now you have an Event/Task combination which will randomize your variables after every turn. You can use this for any variable you would like randomized, not just these two.

Finally, open the ALR file we have been working with in this tutorial and add the following lines:

!Enter-0|enters
!Enter-1|strolls in
!Enter-2|saunters in
!Enter-3|sashays in
!Enter-4|walks in
!Enter-5|arrives
!Enter-6|comes in
!Enter-7|slinks in
!Enter-8|walks toward you
!Exit-0|departs
!Exit-1|leaves
!Exit-2|walks out
!Exit-3|strolls away
!Exit-4|withdraws
!Exit-5|retreats
!Exit-6|exits
!Exit-7|moves on
!Exit-8|walks away

Save your ALR file, then import it into your Adventure. Now save your adventure and run it. If you just stay in the first room and type "look" or "wait" several times, you'll notice that sometimes the other character will "walk in" and sometimes the character will "sashay in". This type of randomization keeps the player's attention and makes your adventure much more enjoyable.

Return to Contents

Randomizing Descriptions: Part II

Next, let's look at an even more complex purpose for randomization using multiple variables in the same description. The setting is the entrance to a circus and we will look at how to randomly change the description displayed when the character types "look" while at the entrance.

First, you need to create the following variables with initial values of "0" for all:

EntranceCrowd
EntranceKids
EntranceSmells

Next, create a room entitled "Circus Entrance" and give it the following description:

You're at the entrance of the circus. There is a banner above the entrance, and a ticket booth with a sign on it. The midway is to the south. !CrowdDesc-%EntranceCrowd% !KidsDesc-%EntranceKids% !SmellsDesc-%EntranceSmells%

Since HTML doesn't effectively display double-spaces, please note that there is a double-space between each of the three ALR entries (in bold) above. Each of the ALR entries will be replaced by a full sentence, so they will need a space between them.

Before editing the ALR you will need to update your Randomization Task to change the values of EntranceCrowd, EntranceKids and EntranceSmells to some random number between "0" and however many descriptions you want to have for each variable (4 would probably be a good number). Finally, add the applicable entries to your ALR file. To save space, only an excerpt of the ALR is listed below:

!CrowdDesc-0|People at the circus are laughing, talking, and eating cotton candy.
!KidsDesc-2|Children with hotdogs and glowsticks are nearby.
!SmellsDesc-1|The odor of freshly popped popcorn hangs in the air.

When you run the adventure and type "look" at the Circus Entrance, you would get the following description when EntranceCrowd=0, EntranceKids=2 and EntranceSmells=1:

You're at the entrance of the circus. There is a banner above the entrance, and a ticket booth with a sign on it. The midway is to the south. People at the circus are laughing, talking, and eating cotton candy. Children with hotdogs and glowsticks are nearby. The odor of freshly popped popcorn hangs in the air.

Every time the player types "look", they will receive a completely randomized description. The possibilities become limited only by your imagination and the time you are willing to put into the adventure.

Return to Contents

Special Uses For Blanks

One final use we will discuss for ALR replacement has to do with blank replacement (replacing the selected text with no text at all). An example of this would be:

!Music-0|
!Music-1|You hear music coming from upstairs.

You would then manipulate a variable for the music (%MusicStatus%) between the values 0 and 1 and include the variable in a description. When the music was on (%MusicStatus%=1), then the text "You hear music coming from upstairs" would display at the end of the description. If the music was off (%MusicStatus%=0), then nothing would be displayed at the end of the description.

Return to Contents

A Final Word on ALR Use

This tutorial covers only a few of the many uses of the ALR file. When used with other aspects of the ADRIFT System, such as variables, you have at your disposal an almost limitless array of possibilities in designing your adventure. It is simply a matter of determining how to incorporate the ALR text into solving a particular problem or just enhancing your adventure. Whatever way you choose to use the ALR file, its concepts are important for both the beginning and advanced user to ensure you achieve everything for your adventure which you set out to achieve.

Return to Contents