How can I have certain text only show up with certain text in a previous passage has been shown x amount of times?

If you are requesting technical assistance with Twine, please specify:
Twine Version:2.4
Story Format: SugarCube

Instead of creating multiple passage flows that do the same thing and cluttering my Twine. I was going to add one passage that had all the variations. E.g. Pet Store Visit, you randomly meet a pet, the pet is from a list of different options found in the same passage. Depending on how many times you visit that pet you get more options in another passage. But the option for other pets are also found in this passage. This saves me creating more passages for the specific pet flows. E.g.

Hope that’s clear

First, there’s nothing wrong with more passages. If the title of these passages is good, it’s easier to edit.

To answer your question, you can set a counter, and each of your paragraphs depend on the level of the counter.

<<if $pet0 == 3>><<set $pet0 to 4>>text and actions<</if>>
<<if $pet0 == 4>><<set $pet0 to 5>>text and actions<</if>>

In this special exemple you might want to add a nobr tag to your passage, to avoid showing long spaces between paragraphs.

You can check how many times a passage has been rendered with the function visited(). For example:

<<if visited("Previous Passage's Name") == 3>>Do this and that.<</if>>

Check the function in the docs.

Hi both thanks for the above. But what I’m looking for is text showing up in a nother passage with visiting a paragraph of a passage in another passage. Is this possible?


You can always brute force it by setting and checking variables. If the paragraph is conditional you can nest other conditionals.

You admire the rich mahogany wood of the writing desk.<<if $drawer eq open>><<set $sawcode++>>The drawer is open. There's something unusual about the woodgrain pattern. if you could just figure it out. It might take some time and repeated examination...<<if $sawcode gt 2>> You finally realize that woodgrain pattern conceals a secret code scratched in the wood at the bottom of the desk drawer!<</if>><</if>>


There's a sturdy door with a keypad that requires a code. <<if $sawcode gt 2>>You know this code from the bottom of the desk drawer!<</if>>

It may not have clicked with you but souppilouliouma did have the right idea.

You haven’t explained how you’re doing these visits within the pet store, but you simply need to increment a counter when the player visits a specific pet, then check that counter within the other location.

NOTE: I’m going to use whitespace within some of the folk examples for the sake of clarity.

For example, in your StoryInit special passage initialize your pet visit counters to 0 (zero, no visits):

<<set $bunnyVisits to 0>>
<<set $ferretVisits to 0>>
<<set $goldfishVisits to 0>>
<<set $kittenVisits to 0>>
<<set $puppyVisits to 0>>
<<set $turtleVisits to 0>>

Then, in the pet store, increment the specific visit counter for whichever pet gets visited:

<<linkreplace "Visit puppy">>
    <<set $puppyVisits to $puppyVisits + 1>>
    You play with the puppy for a while.

I used <<linkreplace>> for this example. However you’re doing the visits, just make the increment of the counters dependent upon doing the specific visits, not simply entering the passage—though you could do that if you were doing a unique visit passage for each pet.

Finally, in the other location, you check the value of the pet visit counters and deliver unique content based upon that:

<<if $puppyVisits is 0>>
    No puppy visits.  You may not need this case.
<<elseif $puppyVisits is 1>>
    One puppy visit.
<<elseif $puppyVisits gte 2 and $puppyVisits lte 4>>
    Two to four puppy visits.
<<elseif $puppyVisits gte 5 and $puppyVisits lte 8>>
    Five to eight puppy visits.
<<elseif $puppyVisits gte 9>>
    Nine or more puppy visits.

You can, of course, also include non-unique content, just outside of the control logic—meaning the <<if>>.


Oh, so all the pets are in the same passage? Then, yes, what I suggested about the visited() function probably won’t work for you.