It’s hard to believe but you are getting to the end of the story. You have a story world that is fully explorable. You have objects placed throughout the world. These objects all have descriptions and they are able to be picked up.
There are a few more things to do. You need to be able to use the game objects. You also need Bernie himself. Finally, you need to provide a win condition and a fail condition. These will all come in time, but in this tutorial, you will put objects to use!
Locking passages
In this story, you’ve already defined three different game objects that act as “keys” in the story. First, you have the flashlight and batteries objects. These allows the player to navigate from the Waterfront to the Tombstone Campsite. This works as a shortcut or an escape route from Bernie since he can’t use the Camp Path. Without the flashlight and batteries, the Camp Path is too dark to navigate.

If you’ve been following this series from beginning to end, you already have all the skills necessary to lock the passage. In fact, you should take the opportunity to try it out on your own.
To get started, open your project in progress, or download the starter project for this tutorial:
Open the Camp Path passage. Update it to the following:
(set: $currentLocation to 15)(if: $inventory contains $flashlight and
$inventory contains $battery) [ Even with the flashlight, the winding path through
the forest is impossible. Yet, you feel at least safe since you know Bernie doesn't
have a light and he would never be able to follow you.
The path leads to the [[Tombstone campsite->Tombstone Campsite]]. Down the hill,
you see the [[waterfront->Waterfront]].]
(else:) [
It's too dark to see. You could see with a flashlight and some batteries.
(link: "Go back") [ (go-to: (history:)'s last)) ]
This is just a simple (if :) macro. It checks to see if the player is carrying the flashlight and batteries. If so, it presents a passage with two links. Otherwise, the only option is to go to the previous passage.
Run the story on easy mode. Go to the Camp Path without the flashlight and batteries. You’ll see the following:

Go back to the Camp Entrance and this time, pick up the flashlight and then camp store for the batteris. Return to the path. You’ll see the following:

Nice work! Now you have passage only accessible with the flashlight.
Adding Bernie’s pickup truck
Now, you need to add Bernie’s pickup truck. Like everything else, the pickup is another passage. To enter the pickup, the player needs the keys, the can of gas and chili recipe. Like other game objects, the pickup is found in the same location on easy mode but is randomized on hard mode.
The pickup truck is the way to enter a possible “win” condition. If the player has the keys, a gas can and the chili recipe, they can drive off to save the day. You won’t add the win condition in this article, but you are getting close!
To get started, open the Setup passage. Add the following before you define your data maps:
(set: $pickupLocation to 1)
It should look like the following:
You’ll randomize it in the next tutorial. For now, it will start at the Camp Entrance. Next, create a new passage. Call it Pickup Location. In the passage, add the following:
(if: $pickupLocation is $currentLocation) [ <br><br>Parked by the side of the road is a neglected [[pickup|Pickup]].]
This checks the current location and if it matches the pickup location, it will display the pickup passage. This links to the new Pickup passage.
You also have your older Pickup passage from when you first implemented a basic inventory system. Make sure to delete these passages as you no longer need them.
Open the Pickup passage. Add the following:
The pickup, parked by the side of the road, looks to be a thousand years old. While it may not make the most stylish ride, it's still a ride and a means to escape the camp.
Now you need to determine if the player has those three items. To do this, you’ll put together one big (if :) check.
Add the following:
The pickup, parked by the side of the road, looks to be a thousand years old. While it may not make the most stylish ride, it's still a ride and a means to escape the camp.
{
(if: $inventory does not contain $carKeys) [
(print: "If only you had the keys to open it.")
]
First, you check to see if the player has their car keys. If they don’t have it, they’ll be locked out. Now for the gas. Add the following:
(else-if: $inventory does not contain $gasCan) [
(print: "If only you had gas to fill the truck.")
]
Like the car keys, the player needs to find the gas can. Following that, add the following:
(else-if: $inventory does not contain $recipe) [
(print: "You need the recipe before you can escape.")
]
The chili recipe is the last item for the player to win. Add the final bit of code:
(else:) [
(print: "You have everything you need to escape. [[Drive Away|Win]]")
]
This provides the win passage. You won’t add it now. Now, provide a link back to the previous passage.
(link: "Leave the pickup") [
(go-to: (history:)'s last))
]
Your entire code block should look like the following:
The pickup, parked by the side of the road, looks to be a thousand years old. While it may not make the most stylish ride, it's still a ride and a means to escape the camp.
{
(if: $inventory does not contain $carKeys) [
(print: "If only you had the keys to open it.")
]
(else-if: $inventory does not contain $gasCan) [
(print: "If only you had gas to fill the truck.")
]
(else-if: $inventory does not contain $recipe) [
(print: "You need the recipe before you can escape.")
]
(else:) [
(print: "You have everything you need to escape. [[Drive away|Win]]")
]
}
(link: "Leave the pickup") [
(go-to: (history:)'s last))
]
With your Pickup passage in place. There’s just one last thing to do. You must place the pickup truck in the story word.
Placing the pickup truck
Your pickup is ready to go. The pickup truck should only appear in certain passages. Like the player’s inventory and room items, you’ll use a tag for this.
To do this, first open the Facilities passage. Create a new tag. Call it Pickup and give it a blue color. It should look like the following:

Next, assign the Pickup tag to the following passages: Facilities, Back Road, Camp Entrance, Side Road, Waterfront, Pondside Road, Intersection, and the Dusty Road.

Finally, you’ll need to call the passage. Open the Location Footer passage. Update it to the following:
{
(if: (passage:)'s tags contains "Pickup") [
(display: "Pickup Location")
]
(if: (passage:)'s tags contains "RoomItems") [
(display: "Room Items")
]
(if: (passage:)'s tags contains "Inventory") [
(display: "Inventory")
]
}
It should look like the following:

Now, run the the story. Right away, you’ll see the Pickup.

Alas, you won’t be able to enter it.

First, get the keys. You’ll be able to find them in the Hopi Campsite. Now, when you try, you’ll need some gas.

You can find the gas at the waterfront. Once you get the gas, you still won’t be able to leave.

You need the chili recipe. Head over to the mess hall and pick up the recipe. Now, you can leave and win the story!

Randomizing the pickup location
Part of the challenge of this story is all the random locations. As players traverse the camp, they’ll need to avoid a wandering Bernie. To make this epecially hard, the pickup should also be randomized.
If you’ve read this entire tutorial series, you’ve already done something similar to this. Open the Hard passage. Add this code just underneath the opening brace:
(set: $pickupLocations to (a: 1,2,3,4,6,13,10,11))
(set: $randomPickupLocations to (shuffled: ...$pickupLocations))
(set: $pickupLocation to 1st of $randomPickupLocations)
It should look like the following:

The pickupLocations refer to the actual passage ids. You then shuffle them together and take the first one. Congratulations! You now have a random pickup location.
Since you are using the random seed, “bernie’s revenge”, the pickup will appear by the Pondside Road passage every time you play the story.

This is great for testing so naturally, when you finish the story, you should make sure to delete that one line of code.
Where to go from here
Congrats! You finished coding the entire campground and related objects. Players can walk through all the passages, pickup items, use them, and even get into the pickup.
You download the final file here:
While you still have a few housekeeping things to do like add images and create an actual win condition, there’s one big missing item from this series. That’s Bernie himself! In the next article, you’ll write the code to have Bernie wander the campground as a traveling NPC. When the player encounters Bernie, they’ll even get to talk to him.
So take a break and when you are ready, head over to the next tutorial.
Discover more from Jezner Books
Subscribe to get the latest posts sent to your email.