Game Development Journal XXII – Keeping Track of In Game Variables

I need a working title for this game…  I’d like it to be something clever about love, time, and friendship.  Any suggestions?  I am bad at naming things.

Now that all of the writing for the various storylines in the game is completed, I turned my eye towards stitching them together.  As I stated in a previous post, I wanted for the game to be able to recognize the repetitions that can crop up in a game about time travel.  So I need the game to keep track of which endings the player has already seen.

The best means I’ve found to do this (I play tested it today and it works!) is to use the assign expression function of Tyranoscript, the TyranoBuilder coding language.

So at the beginning of the game, I set each of the six possible ending variables to a default empty state like this:

[eval exp=”f.endinga=0″]
[eval exp=”f.endingb=0″]
[eval exp=”f.endingc=0″]
[eval exp=”f.endingd=0″]
[eval exp=”f.endinge=0″]
[eval exp=”f.endingf=0″]

Each of these lines of code tells the computer to establish a variable for Ending A through Ending F.  Right now they are all set as “off” or “fasle” or “zero.”

Now lets say that the player goes all the way through the game and discovers Ending A.  Now I need the computer to do a couple of things.  First, I need it to check to see if Ending A has been seen in this play through yet.  Since this is the first ending the player has discovered, the answer is no.  Now I need it to resent the Ending A variable to show that it HAS been seen and to take the player back to the beginning of the game.

Simple right?

But that’s not all.

I ALSO need to enable the computer to be able to divert the player to another location (the repeat acknowledgement screen) IF the case arises that they HAVE seen Ending A already.

In other words, I need the computer to be able to check the value of the variable and to execute one plan in the case that the variable is OFF and another when the variable is ON.

To do this, I use an IF/ELSE statement like this:

[if exp=”f.endinga > 0″]
[jump storage=repeatedend.ks target=*repeatending]
[eval exp=”f.endinga=1″]
[jump storage=firstend.ks target=*firstend]

To translate:

First the computer checks to see IF the variable is ON.  In this case it is not.  So it jumps to the ELSE condition.  The else condition tells the computer to flip the variable to ON and to play Ending A.  Ending A will later tell the computer to head back to the starting screen after it is over.

If the player were to go through the game and find Ending A again, then the computer would check the variable a second time.  However, this time, the switch is already flipped to ON.  So the computer executes the first condition and plays the “repeat” ending.  The switch remains ON so that if the player were to find Ending A a THIRD time (they must be very persistent!) then the same condition would continue to execute.

Next up: I need to figure out how to take the player to the Final Ending, which is only accessible once they’ve found all six of the mini-endings.

This will also require an IF/ELSE statement, but one with several pieces stitched together.  I only want the Final Ending to execute once ALL the switches are flipped to on!

I’ll post once I figure this out.  In the meantime, hit me up with some title suggestions!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s