0 votes
asked by (410 points)

I'm trying to make a series of multiple selectable choices, but after a certain choice made by the user, the next choice needs to be the same regardless of the answer of the previous choice. (Do I need more than just HTML?) The next choices can't be visible when making the previous, but needs to be added under it.

I basically want the same choices to show up without having to type the second choice twice, the thirth choice 4 times, the fourth choice 8 times etc.

(I know just making a passage for each choice will easily solve my problem, but being to do it in one passage is preferable to me.)

What I already have. A problem is under "Choice 1" for example.

<span id="Answer"><<print $answer>>
<<click "[Choice1 A]">><<replace "#Answer">>

*Right here I would like Choice 2 to show up.*

<<click "[Choice1 B]">><<replace "#Answer">>
	<span id="Answer2"><<print $answer2>>
	<<click "[Choice2 A]">><<replace "#Answer2">>
	<<click "[Choice2 B]">><<replace "#Answer2">>
		<span id="Answer3"><<print $answer3>>
		<<click "[Choice3 A]">><<replace "#Answer3">>
		<<click "[Choice3 B]">><<replace "#Answer3">>
			[[next passage]]


1 Answer

+2 votes
answered by (22.3k points)

I'm not entirely sure what you want. Can you try explaining it in more detail?

You can use <<linkreplace>> to have a single link execute some code and be replaced with another link without having to transition to another passage, You can do the same by combining a simple <<link>> with <<replace>> as you are already doing in your code (you shouldn't use <<click>> just use <<link>> instead).

If you want the user to be able to see previous choices instead of replacing them, you can use <<linkappend>> instead.

commented by (410 points)
edited by
Thank you. I want to have multiple 'linkreplace' in the same passage. But the ones after can't appear unless the previous link has been clicked on.

Edit: Also, linkreplace doesn't seem to work with multiple options where one choice dissapears when clicking the other. (Or at least I don't know how.)
commented by (22.3k points)

<<linkreplace>> only replaces the link itself. For what you describe you might work with a <<switch>> statement and just reload the passage. With the following in your StoryInit:

<<set $answer to "Initial Statement">>
<<set $counter to 0>>

You could have the passage like this:

<<switch $counter>>

<<case 0>>
<<link [[Choice 1A|passage() ]]>>
	<<set $counter++>>
	<<set $answer to "Answer1A">>
<<link [[Choice 1B|passage() ]]>>
	<<set $counter++>>
	<<set $answer to "Answer1B">>

<<case 1>>
<<link [[Choice 2A|passage() ]]>>
	<<set $counter++>>
	<<set $answer to "Answer2A">>
<<link [[Choice 2B|passage() ]]>>
	<<set $counter++>>
	<<set $answer to "Answer2B">>

<<case 2>>
<<link [[Choice 3A|passage() ]]>>
	<<set $answer to "Answer3A">>
[[Choice 3B|NextPassage]]



commented by (410 points)
This works great. I just needed to add an if-statement for text.
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.