PPD Builder Help - Flags and Conditionals


Builder Guide
1 - Basics
2 - Chapter Editor
3 - Actor Editor
4 - Interactions
5 - Flags and Conditionals
6 - Graphics


Games would be pretty boring if they didn't allow the player to make any difference in how the story played out.  To accomplish this, we're going to need some way to have the game change as the player plays it, and also a way to recognize these changes as we progress.


Part 5 - Flags and Conditionals

If you've read the other sections of this guide, you no doubt have noticed many editors for various game elements have something that looks like this:


This is a Conditional editor, and in this section we're going to learn what a Condition is, how they relate to Flags, and some of the best ways to use them.  Since Flags and Conditionals are so closely tied together, this section will cover both.

5a - Flags
The idea of a Flag is quite simple, but for potential builders who are new to this sort of thing, the practical usage for Flags may not be immediately clear.  Don't worry, once we work with some Conditionals, it will probably make a lot more sense.

For now, just think of a Flag as a place to store information that you might want to know later.  Builders with scripting or programming experience will probably be familiar with this concept, since in programming terms a Flag is just a variable.

Let's create a Flag or two and see what we can do with them.

To see what Flags you have in your game, click the "Global Flags" button on the workspace toolbar.


This opens up our Flags list.


This list functions identically to many of the other Builder lists we've come across.  To add a new Flag, just click the "+" button at the top.


Now we've got a new, empty flag.  One thing to keep in mind with Flags, is that they are top-level elements (just like Chapters or Interactions).  A Flag is not tied to any particular Chapter, Interaction, Conditional, Actor, or anything else.  Flags are the same across all elements of your game.  So you can (and will) use the same Flag in many different places, and they all reference the same Flag.

Our default Flag isn't very interesting.  Let's open up the editor for it by clicking the "E" button.


The Flag editor is simple enough.  Since Flags are mostly Builder elements and aren't directly interacted with by the player much, we use a Tag to denote them.  If you've read the other sections of this guide you'll be familiar with Tags.  Tags are a way to name elements in the Builder for your own reference, and are never seen by the player.

I'm going to be using this flag to store a character's mood.  Depending on the value of the Flag, the character is going to react to the player in a different way.  I'll change the Flag's Tag and starting value to reflect my intention.


Now just click "Set" to save our Flag.


We've successfully created our Flag.  It's going to called "hatman_mood" in our game (that's the name it will show up as in all the other editors).  When the game starts, it's going to have the value "neutral".

Note that Flags can have any sort of value you want.  Flags can be numbers or text, depending on what you want them to do.  However, if you plan on doing math operations on a Flag, it should probably be a number.

Now let's see what we can do with our new Flag.

5b - Changing Flags
Flags would be pretty useless if they were stuck with their starting value.  Let's make our new Flag changeable by player actions.

To do so, I'm going to open up the Interaction I created in the last section, Part 4 - Interactions.  If you want to follow along, I recommend completing that section first.  However, the concepts I cover here are easily applicable to your own Interactions.


Here's our Interaction with Hatman, tagged "hatman_speak."  To add some additional interactivity to this conversation, we're going to add a couple additional Triggers.  If you want to learn more about Triggers, check out the previous section of this guide (Part 4 - Interactions).

We have two player responses that we want to change Hatman's mood (and therefore, our new Flag).  The first response ("I'm sorry to hear that.  I hope your dog get's better soon.") is going to make Hatman happier.  Let's open up that response node's editor and add a new Trigger.


We're going to be making a "setFlag" trigger to set our Flag to a specific value.  Let's see what that looks like.


For the Flag, we obviously want our new Flag "hatman_mood" to be selected.


The second element needs a little explaining.  You'll notice theres a small button labeled ">>" to the right of the text box.  This means this editor element has two modes.  To change the mode, just click the button.


This lets us set our Flag to either a value that we type in, our you can set a Flag to the value of another Flag at the time of the Trigger's firing.  For now, we're just going to be setting our Flag to a constant value.  So let's toggle the mode back to the text box and fill it in.


And that's it for this Trigger.  After clicking"Set" to save this Trigger, we'll add a similar Triggers to our other responses that we want to change Hatman's mood.


You might notice we added a setFlag Trigger to the line that says "I've got to go.  See you later." which sets our Flag back to neutral.  This is so the player can get Hatman back to his neutral mood if he's been made angry or happy.

Now that we've given the player the ability to change our Flag, let's see how we can make the game respond to the player's actions.

5c - Adding Conditionals
Conditionals can be added in a wide variety of places, but they function the same everywhere.  The idea of adding a condition to an element is to prevent it from showing up for the player if a Flag has a certain value.

Let's use Conditionals to change the way Hatman greets the player in our Interaction.  To start with, we're going to add two more root nodes to the Interaction.


These two nodes will contain Hatman's other responses.  Let's change them to make Hatman respond positively and negatively to the player.


We want these roots to only appear when Hatman's mood (represented by our Flag) has a certain value.  So let's open up the editor for the first response and add a Conditional.


Just click the "Add" button in the top right to open the Conditional editor.


The Conditional editor has a lot going on in it, but it's not very complicated.  For a new Conditional, there's two blank text boxes that represent the arguments of your Conditional.  For pretty much every Conditional, one of these is going to be a Flag.  If you remember adding setFlag Triggers, the ">>" button should look very familiar.  These argument editors function exactly the same way here as they did in the Trigger editor.  Just click the ">>" button to switch to Flag mode.


This is the format that most Conditionals end up looking like.  Let's select our Flag from the drop-down list.


The next field is the operation you want to check your flag with.  Let's see what our options are.


These might look a little confusing to builders with no scripting or programming experience, but they're really quite simple.  From top to bottom we have:

Equals
!= Does not equal
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to

The greater than/less than operations only apply to numbers.  You can use the equals and does not equal operations for words and numbers.

For our Conditional, we want this node to show up if Hatman is happy.  So let's set our Conditional to say if "hatman_mood = happy" display this node.


That's it.  Now, if we want to save this Conditional, we click "Set."  If we want to discard what we've done and go back to what we had before, we click "Cancel."  If we want to clear this Conditional out completely so this node no longer has one, we click the "X" button on the top right.

Since I want to save my Conditional, I'm going to click "Set."


Notice that the "Condition" text is now highlighted green, which means we have a Conditional active for this node.

Let's add Conditionals to our other nodes.  Remember, in Interactions, the game will start at the first root node at the top and go through the root nodes until it finds one it can display.  So we need to also add a Conditional to the first root node.  This one will check if Hatman's mood is "neutral."


And finally, let's add a Conditional to the last root node to check whether or not Hatman is "angry."


That's really all we need to do.  For the sake of the Interaction, we should add node transitions to each of our new nodes to point to the first child node of the first root:


You can check out the previous section, Part 4 - Interactions to learn how to do that if you're confused.

Our Interaction is ready to go, but that isn't the only place you can use Conditionals to add interactivity to your game.  Another common place is in Area Descriptions.

Let's add a some Conditional mojo to our very first area that we created way back in Part 2 - Chapter Editor.


Look familiar?  Well, let's mix things up a bit.  I'm going to go ahead and delete our old Area Descriptions so we can add some more interesting ones.


I highly recommend alluding to the Actors you have in an Area in the Area Description.  This creates a connection to the Actors in the player's head while they're reading, and draws attention to your Actors (instead of having them just be there).

With that in mind, let's create a different Area Description for each of Hatman's moods, as well as a default one (just in case).


Notice I've differentiated my descriptions with Tags.  Next, I'll go through and add the Conditionals, as well as write some text for each description.


And the rest...


All done!  Now the text the player sees when they enter the area (or finish speaking with Hatman) will change depending on what they said to him.

There's a lot of other uses for Conditionals that you'll find while using the Project PD Builder.  However, there's one more feature of Flags themselves that may not be very obvious.

5d - Display Flags
It's true that most Flags are never seen by the player, but occasionally it can be very useful to have a Flag simply display for the player instead of going through the hassle of creating multiple elements with Conditionals to accomplish the same thing.

Displaying a Flag is quite simple, and can be done in any text display that the player sees.  Let's open up our "default" description and add a special keyword to display the flag's value.


The key is the "<hatman_mood>" text.  When the game is played and the player sees this description (which means Hatman's mood is something other than neutral, happy, or sad) the <hatman_mood> text will be replaced by whatever that Flag's value currently is.  Quite simple, really!

Of course, with our current game, the player won't ever see this description, since Hatman's mood will always be neutral, happy, or sad.  But maybe in the future will add more options for changing Hatman's mood.  It's up to you!

This section of the guide only barely scratched the surface of the possibilities of Flags and Conditionals, but it's up to you to figure out how the tools best work for you and your game ideas.  There are a lot of different ways to get the interactivity you want from your game (if you want any at all!), and the best way to figure them out is to experiment.

The next and final section, Part 6 - Graphics, will go over how to add some visual flair to your game.

No comments:

Post a Comment