Howdy, Stranger!

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

New to Twine - Need Help Achieving This!

Hello,

So I have just started using Twine for my story and I wanted to know if a thing is possible, been trying to achieve it for few hours now.

Suppose in my game, I ask a question to the user which has 4 reply choices - A, B, C & D.
The user selects choice B.

Now, in my next question, there are again 4 choices (E, F, G, H) out of which 3 are generic but I want the 4th one (H) to be changed according to whatever choice the user chose earlier.

So what I have done is, I have created a total of 7 choices for this question - E, F, G are generic choices and H1, H2, H3, H4 which are linked to A, B, C & D respectively. So if the user selected the choice B in previous question, I wish to show E, F, G, H2 as choice options in the next question. How do I achieve this? Do you get what am I trying to say?

Comments

  • You need to state which Story Format 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 but my answer can also be done in SugarCube but the syntax of the code will be different.

    You can use variables to track the Reader's choices and then change what is shown to them based on the value of the variable.

    1. A passage named Question 1

    Use a (link:) macro combined with a (set:) macro and a (go-to:) macro to show a link that first assigns a value to a $variable and then moves them to the next passage when the link is selected. This type of link is generally known as a Setter Link.
    Question 1: Blah Blah Blah
    
    Answer:
    (link: "A")[(set: $answer1 to "A")(go-to: "Question 2")]
    (link: "B")[(set: $answer1 to "B")(go-to: "Question 2")]
    (link: "C")[(set: $answer1 to "C")(go-to: "Question 2")]
    (link: "D")[(set: $answer1 to "D")(go-to: "Question 2")]
    

    2. A passage named Question 2

    Use an (if:) macro or the related (else-if: ) macro and (else: ) macro to check the current value of the $answer1 variable to determine which Setter Link should be shown.
    The following includes Collapsing whitespace markup to stop an extra line break appearing between choice G and whichever H link is shown.
    Question 2: Blah Blah Blah
    
    Answer:
    (link: "E")[(set: $answer2 to "E")(go-to: "Question 3")]
    (link: "F")[(set: $answer2 to "F")(go-to: "Question 3")]
    (link: "G")[(set: $answer2 to "G")(go-to: "Question 3")]
    {(if: $answer1 is "A")[
    	(link: "H1")[(set: $answer2 to "H1")(go-to: "Question 3")]
    ] (else-if: $answer1 is "B")[
    	(link: "H2")[(set: $answer2 to "H2")(go-to: "Question 3")]
    ] (else-if: $answer1 is "C")[
    	(link: "H3")[(set: $answer2 to "H3")(go-to: "Question 3")]
    ] (else:)[
    	(link: "H4")[(set: $answer2 to "H4")(go-to: "Question 3")]
    ]}
    
  • Apologies for not mentioning the story type, I am using Harlowe. And thanks for the solution, I am going to understand it and try it out. Will post here if it works for me or if there's any issue. Thanks again!
  • edited August 2016
    So I tried your solution but it doesn't seem to work for some reason.

    Here's what I wrote for my 1st question passage:
    (link: "Are they even trying?")[(set: $tclass1 to "A")(go-to: "Are they even trying?")]
    (link: "The test was easy")[(set: $tclass1 to "B")(go-to: "Easy test")]
    (link: "Ms. Susan")[(set: $tclass1 to "C")(go-to: "Ms. Susan")]
    

    And here's what I wrote for my 2nd question passage:
    {(if: $tclass1 is "A")
    [(link: "Did anyone else try?")(go-to: "Did anyone else try?")]
    (else-if: $tclass1 is "B")
    [(link: "It was easy!")(go-to: "Easy")]
    (else: $tclass1 is "C")
    [(link: "Have you tried solving it?")(go-to: "Have you done it?")]}
    
    The problem is, whenever I go to the 2nd passage, it doesn't show me the options as per my last answer and automatically goes to the "Easy" passage whenever I load this passage. What am I doing wrong?
  • dude don't try it the smart coding way, try it the "dumb" way will take you way less time and has no coding involved: simply make passage 1 with answers a, b, c, d ; a links to passage 2, b links to passage 3 and so on, and now just copy and paste your generic answers and type the individual one separately now while this way too stupid and dumb it will take you about 5-10 min while the coding will take you few hours and with glitches, errors and bugs along the way and you still have to actually type it one by one you can't paste here
  • edited August 2016
    I agree that often the simplest solutions are the best. I use the repeated passages method a lot.
  • nedd wrote: »
    Here's what I wrote for my 1st question passage:
    (link: "Are they even trying?")[(set: $tclass1 to "A")(go-to: "Are they even trying?")]
    (link: "The test was easy")[(set: $tclass1 to "B")(go-to: "Easy test")]
    (link: "Ms. Susan")[(set: $tclass1 to "C")(go-to: "Ms. Susan")]
    
    Each of the (go-to:) macros in your first passage are targeting a different passage, where the (go-to:) macros in my first passage all targeted the same passage.

    Because you are sending the reader to a different passage for each link there is no way the $tclass variable in the target passage can have more than a single value.

    eg. In your Are they even trying? passage $tclass1 will always equal "A", in your Easy test passage $tclass1 will always equal "B", etc...

    nedd wrote: »
    And here's what I wrote for my 2nd question passage:
    What is the name of this second passage, is it the Are they even trying? passage, is it the Easy test passage or is it the Ms. Susan passage?
Sign In or Register to comment.