Course: Programming.
I promise you that it’s not actually as bad as it seems, but I’ll do my best to make sure that you have enough examples to work from. I’ve actually attached an html file to this module, which you can download and open up in Twine to see some examples of how to use variables. The examples in the file are a bit silly, but hopefully you can see how to set up your variables and conditions and how those get integrated into your stories. Regardless, if after reviewing the material, you are still having trouble understanding how to implement variables and conditions, please make an appointment with me. In most cases, it’s easier for students to understand these concepts if I can explain them in person.
Anyways, a few notes:
Think of variables as “containers of information”. What information or data do you need to keep track of in your story? This info could be anything: keys, steps, time, dog toys, flowers, # of text messages, etc.
Once you have that, you “set” your variable like so: (set: $steps to 1).
You’ll notice that if you’ve done it correctly, the whole line will change color. If you finished typing and it didn’t change color, then something is amiss.
Twine reads variables and conditions in the order in which they appear. So if you (set: $steps to 1) at the beginning of the passage, and then (set: $steps to 3) at the end of the passage, the value of $steps will be 3 as you move to the next passage.
Following the example above, if you want to keep track of how many steps a player has taken, remember that Twine won’t necessarily know what the incoming value is from the previous passage. So to account for that, you’ll write it like this: (set: $steps to $steps + 1). This will add “1” to the value of whatever $steps was. So if $steps was 5 at the end of the previous passage, it will be 6 after this line.
Overall, it will be easier to start thinking of this project more as a video game, and less as just a story. Hopefully at this point, after playing through at least the first two episodes of your TellTale game, you can see how variables and conditions might be applied to a story like yours.
Download