Revealing new text when a passage is revisited

Twine Version: 2.7.0
[also choose a Story Format tag above]

Hello,

My question is, I want Passage A to display new text if the Player moves from Passage A to Passage B, and back to Passage A again. And I would like that text to change depending on which visit the Player is on.

1st time at Passage A: “This is your first time here.”
2nd time at Passage A: “This is your second time here.”
3rd time at Passage A: “This is you r third time here.”
etc.

I worked out a way to get the text to change once by having Passage A check to see if a variable was true, and toggling that variable to true in Passage B. But I can’t find a way to go beyond that. Is this possible?

It looks like visits might be what you need.

Is there an example of using visits to check and see if a passage was visited X number of times?

Screen Shot 2023-08-23 at 1.52.58 PM

1 Like

Thank you. This worked, except that it treats the second visit as though it is the first also (I get the same text back on visits 1 and 2). Meaning, I see it the first time I visit, then move to a new passage, return to this passage and I see it again. Each subsequent visit does seem to count the way I would expect.

(if: visits is 1)[You see a $adjective $citizen. They appear quite distressed. Clearly in need of help, they try to stop someone, anyone, but no one seems to have time for them. Perhaps you could help?]
(if: visits is 2)[You go back to people gawking. This time you spot a $adjective $citizen, also in need of assistance.]
(if: visits is 3)[This is a test]
}```

Does it matter that all paths back to this passage refer to this passage through (display: "test passage")?

Because the visits related conditional expressions are Mutually Exclusive (eg. only one of them can be true at any time) the 2nd and later (if:) macro calls in the set should be replaced with (else-if:) macros.

The following Twee Notation based example has the behaviour you asked for. Each of the first three visits to Passage A will show a different message, the forth and later visits will show no message.

:: Start
[[Passage A]]

:: Passage A
{
(if: visits is 1)[This is your first time here.]
(else-if: visits is 2)[This is your second time here.]
(else-if: visits is 3)[This is your third time here.]
}
[[Passage B]]

:: Passage B
[[Passage A]]

Does it matter that all paths back to this passage refer to this passage through (display: “test passage”)?

  • The (display:) macro includes the contents of the referenced ‘child’ Passage inside the ‘parent’ Passage that calls the macro.
  • The visits keyword/variable represents the number of times a Passage has been visited, not the number of times a Passage has been displayed inside another Passage.

My bad! Somehow it worked on my system. When I worked in AXMA the visits were not cumulative so ‘visit 2’ did not flag true on <<if visited() = 1>> (which is AXMA format very similar to Sugarcube.)