Ways to use a single Twine passage repeatedly
We can use a passage repeatedly by incrementing a story variable that is used with a <<switch>>
to select what the passage should display.
The way I do this is to define a widget like so (be sure the passage in which you define the following widget has a widget
tag:
<<widget lb>>
<<goto $p>>
<</widget>>
Then, in special passage PassageDone I put this code:
<<set $p to passage()>>
The above sets story variable $p to the name of the most recently rendered passage.
Using the above, we can then do the following in the passage we want to repeatedly use (assume the passage name is MyPsg
):
<<switch visited()>>
<<case 1>>
Case 1 text goes <<link here>><<lb>><</link>>.
<<case 2>>
Case 2 text goes <<link here>><<lb>><</link>>.
<<case 3>>
Case 3 text goes <<link here>><<lb>><</link>>.
<<default>>
Text for after the third passage visit.
<</switch>>
Here's another way you can accomplish this (I prefer the method used above):
<span id="start">
This text will be displayed when the passage is first loaded.
</span>
<<set _count to 0>>
<<link "Continue">>
<<set _count++>>
<<replace "#start">>
<<switch _count>>
<<case 1>>
This text will be displayed when the "Continue" Link is clicked the first time.
<<case 2>>
This text will be displayed when the "Continue" Link is clicked the second time.
<<case 3>>
This text will be displayed when the "Continue" Link is clicked the third time.
<</switch>>
<</replace>>
<</link>>
→