0 votes
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">>
	Choice1

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

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

 

1 Answer

+2 votes
by (23.6k 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.

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.)
by (23.6k 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:

$answer
<<nobr>>
<<switch $counter>>

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

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

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

<</switch>>
<</nobr>>

 

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.
...