Howdy, Stranger!

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

Adding extra information to a passage

edited December 2015 in Help! with 2.0
I'm not sure how to do this, I've read through basic coding stuff (waiting to get to the more complicated things later) but I've come to an impasse.

I have a passage with two different options to move on. Both of them lead to the same passage. Is there any way to add extra information to that passage depending on which option was chosen?

For example, one option says "Hello?" and the other says "Hello, what's your name?" I want the response to be the same, but in the second option a name would be provided to the reader. Help?

Comments

  • Greetings!

    First of all, always state what story format you're using. I'll have to assume you're using Harlowe since you posted in the Twine 2 section and it's the default.

    Next, become familiar with the following two links:

    http://twine2.neocities.org/
    http://twinery.org/wiki/twine2:guide


    Now, what you're seeking was known as a "setter link," but I didn't see how to create one at first glance in the new markup guide. I'm sure it's there.

    Here's the standard way of using a link to set a variable:
    (link:"Link Text")[(set: $foo to 1)(goto:"Passage Name")]
    

    Clicking the link will set the variable called "foo" (without quotes) to '1' (without single quotes).

    Here's how it could be used, for example:
    Start Passage
    
    You find a little orphan child in the back alley. 
    
    What do you do?
    
    * Say (link:"Hello?")[(set: $hello to 1)(goto:"Second Passage")]
    * Say (link:"Hello. What's your name?")[(set: $hello to 2)(goto:"Second Passage")]
    

    Then, in the second passage, you could use an if conditional branch to display additional text if the player asks the orphan's name, like so:
    Second Passage
    
    The orphan turns to face you when you say hello. 
    
    (if: $hello is 2)["My name is Pip," the orphan replies.]
    

    In the example, the orphan only replies with his name if asked.


    Attached is an HTML file of the example that can be played and imported into Twine 2.

    Hope that helps!
  • edited December 2015
    You need to state which story format you are using when asking a question, as answers can be different for each one. I am going to assume you are using the default which is Harlowe.

    You can use a variable to track the reader's selection in one passage and then conditionally change what is shown in the new passage, how you do this is different for each story format.

    1. The passage containing the options:
    (set: $showName to false)
    
    [[Hello->Response]]
    (link: "Hello, what's your name?")[(set: $showName to true)(goto: "Response")]
    
    2. Response passage:
    Hello. (if: $showName)[My name is Inigo Montoya. ]You killed my father prepare to die!
    

    edit: you got two answers at the same time for the price of one. lol
  • Ah, sorry about not stating the story format.

    Thank you both, it worked. Sharpe, I'll definitely take a look at those links at length.
Sign In or Register to comment.