Saving Variables
Alright, lets talk variables. Remember in Algebra when x = 12... and then you used x in an equation? Variables in an avatar are just like those math variables. A variable has a name, and a value. Here's an example:
favorite_pet = dog
The way you type these is important. We use underscores between words. And lowercase letters. Make sure the equals has one space before it and one space afterwards.
Alright... so what's the point of saving variables? Can't we already go down different paths based on the user's answer as seen below?
Yes, you are right... but what if we want to remember the answer they gave for a later part in our conversation? In order for our avatar to "remember" something we need to save it as a variable. Here's how that looks:
Notice how the second line of each button is an assignment to save a variable. They all use the same variable name, but each assigns a different value. The syntax here is important. The setting of a variable happens on the next line, with no additional returns in between.
Great! Now we've got some variables saved... but what can we do with them? Variable can be used for several things, including:
You can also have the user input a custom value for a variable, like typing in a partner's name or a favorite hobby.