Note: This tutorial assumes you have knowledge from the Getting Started tutorial. If you haven't done so yet, we recommend you read and complete it before continuing.
Locations are another way to add interactivity to a story by giving it a sense of place.
The player's character can only be in a single location at any time and any time a player enters a new location, that location's description is written to the screen.
Create a new story named Spooky Tutorial. Under Start Options select Location. Name your starting location DOWNSTAIRS. Click Save Story.
Instead of running the INIT message, the Location start option starts the player in a specified location. When the story begins, the location's text will print to the screen.
Select your new DOWNSTAIRS location on the left. Give it a title of Downstairs and in the text area type in something like Dust and cobwebs cover the furniture. There are stairs here. Click Save Location and Test Story. You should see the location's title at the top and the text should print to the screen.
Exits let the player move from one location to another. Every time the player enters a new location, the location's text will run and the results will print to the screen.
Edit the DOWNSTAIRS location and click Add Exit at the bottom. Type Go upstairs as the exit's text.
Select New Location... and name it UPSTAIRS. Leave Visible By Default on. Edit the UPSTAIRS location by clicking it on the left. Name it Upstairs, and add the text It is so dark you can barely see.. Click Save Location and Test Story and test your exit.
Exits are one-way. You have to make both sides of the exit if you want to go back and forth.
Edit UPSTAIRS. Follow the previous steps to add an exit from UPSTAIRS back to DOWNSTAIRS. Click Test Story. You can now go back and forth between locations.
Location text is good for descriptions of where the player just entered, but sometimes you only want text to appear the first time the player enters a location.
Wrdie keeps track of the locations the player has visited and allows you to check them with the if visited tag. Just like if tags, an if visited tag must be closed with an endif or else the location will not run.
Drag an if visited and an endif tag into the text for DOWNSTAIRS. Edit the tag and set its condition to if not visited and the location name to DOWNSTAIRS. Add some exposition between the tags, something like You aren't sure why you took the dare, but now that you're in here you'll have to find that upstairs window or else the other kids will all think you're chicken.. Click Save Location and Test Story. Your text should only appear when the story starts and not reappear when you re-enter DOWNSTAIRS.
Now let's use an if visited to make things a little spookier.
Click on the UPSTAIRS location to edit it. Add an if visited and endif to the text. In between write A shadowy figure stands before you. She points to an antique sconce on the wall. Set the tag's condition to if visited and the location to UPSTAIRS. Click Save Location and Test Story. The ghost should only appear the second time you go upstairs.
You can add commands to location based stories just like we saw in the Getting Started tutorial by using the Add Command tag.
However, sometimes a command should only appear when the user is in one specific location. An example would be a switch on the wall that you can toggle or a key on a table for the player to take.
For these, you can use a Location Specific Command.
Edit UPSTAIRS and click Add Command at the bottom. Make the text Pull the sconce and create a new message named PULL-SCONCE. Click Save Location and then edit your new PULL-SCONCE message by clicking it on the left. Write There is a loud creaking noise behind you. When you look back, the shadowy figure is gone. Click Save Message and Test Story. Your new command should appear only when you are upstairs.
Sometimes a command or exit should only appear under certain circumstances. For this you can control their visibility.
Let's change the visibility of our new command so that it shows up only after the ghost appears.
Edit UPSTAIRS and toggle Visible by default to off for the Pull the sconce location command. Now drag a Show Command tag in between the if visited and endif tags and set the command to Pull the sconce. Click Save Location and Test Story. The command to pull the sconce should only appear after the ghost tells you about it.
You've probably noticed that locations also have a text area called the Post Run Trigger. While the location text runs when the player enters the location, the post run trigger runs both after entering the location AND after any command that runs while the player is in the location.
If something in the location needs to change after a command runs, you need to use Post Run Trigger. One example is showing a hidden door after a user presses a button (or pulls on a sconce).
We'll do this in a few steps. First we need to make the new location and exit.
Edit UPSTAIRS and add click Add Exit. Make the text Open the door and create a new location called BEDROOM. Set Visible by default to off. Add some nice text like You look out the window onto the sunny front yard and wave at your friends outside.
Next, we'll add a global that changes when we pull the sconce.
Edit the PULL-SCONCE message. Drag in a Set Global tag and use it to create the new PulledSconce global of type Boolean (Booleans can only be true or false). Have the tag set it to true. Add some text at the end of the message text, like A door appears on the wall.
Finally, we'll use the post run trigger to check our new global and show the new exit if it's true.
Edit the UPSTAIRS location. Drag an if and endif tag into the post run trigger area. Modify the if to check if PulledSconce is true. Drag a Show Exit tag in between the if and endif and set the location to BEDROOM. Click Test Story.
VERY IMPORTANT: Before you test, make sure to set PulledSconce is unchecked in the form, this will make sure that it is set to false when you start the story.
Now when you pull the sconce, the door should appear and you can use it to wave to complete the dare.
Locations open up your stories by letting the player drive the action themselves. While feeling completely open ended to the player, you can make clever use of globals and conditionals to still control your story's pacing and structure.