Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Counting things?

I wasn't really sure what else I could set the title to, so... Yeah.

My question has to do with counting things. Specifically, I want a counter to go up whenever the player enters certain passages, and when the counter reaches a certain number, those passages will display a secret message. To give you a better idea of what I want, I'll tell you what exactly I'll do with it.

My game has some stupid options, so I decided to make a game of those options. If you are as stupid as possible, clicking all of the stupid links, you will get a message the next time you're stupid saying "Walnut' earned!" Walnut being the name of an achievement in the game. I'm having problems getting the whole "(count: (history:)" thing to work, so I decided I would just make a counter go up when you visited the stupid pages, and when the counter is high enough, the message pops up. However, I have no clue how to do this. Here's a sort of model depicting what I want to happen.

A thing happened! You...
Be logical
Be logical
Be stupid (Hint: The player chooses this one)

You died. That was pretty stupid of you. (The game tells you when you made a stupid choice so you know if you're making progress on the achievement.)
[An invisible counter goes from 0 to 1]


Another thing happened! You...
Be logical
Be logical
Be stupid (Again, the player picks this one)

You died. You're pretty stupid.
[An invisible counter goes from 1 to 2]
[The game realizes the counter is at the point where the message should pop up, so the next time the player is stupid...]


You died. Wow, you're stupid.
"Walnut" earned!



This is getting long, so TL;DR: How can I make a counter go up when the player picks certain options, and when the counter is high enough, a message appears on one of those options?

Comments

  • You need to state which story format (both name and version) you are using when you ask a question, as answers can be different for each one. I am going to assume you are using Harlowe which is the default in Twine 2.

    You can use a variable to track the counter part and use an (if: ) macro to handle the conditionally showing something part.

    1. Initialising your variable.
    Ideally this should be done in your story's startup tagged passage but it can be done any time in your story before the first passage that needs to increase the counter. You do this using a (set: ) macro like the following, you can name the variable anything you like but in this example it will be $counter.
    (set: $counter to 0)
    


    2. Increasing the variable.
    You also use a (set: ) macro to do this and it should be done early in each passage you want the counter to go up in. The following example also uses a backslash character to remove the line-break between the (set: ) macro the the rest of the passage content.
    (set: $counter to it + 1)\
    The rest of the content of the passage.....
    


    3. Checking the current value of a variable.
    As I stated before you can use an (if: ) macro to do this.
    This can be done either in each of the passages you want the message to appear in, or it could be done in a footer tagged passage which would automatically add the message to the end of the current passage.
    (if: $counter is 1)[Counter equals one]
    
Sign In or Register to comment.