Displaying a game score

Old-school Sierra adventure games in the 90s often had a score system that tracked player progress. They're not in vogue so much these days, but they're a good way to demonstrate how variables work in AC!

First, go to the Variables Manager, and click Create new Global variable. Global variables can be accessed from anywhere in our game.

Set the type from Boolean to Integer, and give it the name "Score", leaving the default value as 0.

Then create another Integer, calling it "MaxScore" and giving it a default value of 250.

We can use the Variable: Set Action to increase the Player's score - e.g. when they solve a puzzle. From any ActionList (e.g. a Cutscene or Interaction), create such an action. Set the Variable to affect as Score, and change the Method to Increase By Value. Then enter 10 into the value box.

When this action is run, the Player's score will be increased by 10.

The value we increase the score by can be parameterised, so that we can set it dynamically each time. For more, see this tutorial.

Now let's create a Menu to display the score. Go to the Menu Manager and click Create new menu underneath the list of Menus. Give it the name "ScoreBox".

We want this Menu to be shown during regular gameplay, so set it's Appear type to During Gameplay. Change it's Position to Aligned, and Alignment to Lower Right.

Now we'll create a label to actually display the score. Under the ScoreBox elements heading, choose the Element type Label, and click Add new.

We want our label to read something like "Score: 5 of 120", where the 5 and 120 are the values of our Score and MaxScore variables respectively. To do this, we’ll make use of tokens.

Back in the Variables Manager, notice the Replacement token listed in each Variable's list of properties - for Global Variables, they'll be of the form [var:X]. The tokensihere are [var:0] for Score, and [var:1] for MaxScore, though yours may vary.

Going back to the Menu Manager, enter these tokens into the Label's Label text field. In my case, I'll write Score: [var:0] of [var:1]:

At runtime, Adventure Creator will convert these tokens into the values of the actual Variables.