Twine room count

Big apologies, but I have no idea what I’m searching for.

I have a series of locations that the MC will be returning to and I think I may need some variable but Im not sure.

I want to set it up so that when he returns to the room the events in the room are different to his first visit (the room is the same just the events in the room are different).

Sorry, i’m new to twine.

So you want each visit to that passage to display different text, right? Which format are you using? The way you write it is different for each format.

Sorry, I did say I was new to twine!

Using Harlow 1.22

No worries!

So you want to set up a conditional using the (count:) and (history:) macros together. For instance,

(if: (count: (history:), “Start”) = 0)[You gently push open the door and peer into the darkness.](elseif: (count: (history:), “Start”) = 1)[You loop back to the front door and notice that it has been closed by an unseen hand. You push it open one more time.]

So you’re nesting the (history:) macro inside the (count:) macro and asking Twine to check the history list (which is just a list of read passages it is generating) and see if the Start passage is on there. If it isn’t, you’ll see the first bit of text: You gently push open the door and peer into the darkness. If the Start passage is on the list once (meaning, you’ve read it once), you’ll see the second bit of text: You loop back to the front door and notice that it has been closed by an unseen hand. You push it open one more time.

You can keep that list going as long as you wish with (elseif:) options. Or use operators like

(if: (count: (history:), "Start) <= 3)You finally hear Pete call out, “I’m over here!”[The silence feels like a heavy blanket.]

So that text will display (You finally hear Pete call out, “I’m over here!”) if the player has been through that passage more than three times.

You can nest anything else inside those hooks: links out of the passage, the (set:) macro, etc.

Does that help?

One note to be made: you’ve got to be careful if you’ve got any “Restart” or “Go back to start” links, because as far as I know only incidence in which the object exposed by (history:) gets set back to zero is if the whole Twine is reloaded. So the takeaway is that if they’ve already gone to that room 3 times, then click a link “restarting” the game, they’ll never see the <3 visit text.

For that reason, if you’re planning on having a Game Over or Restart-type mechanic, it might be better to use your own variable rather than (history:) – set that variable to 0 in a passage they can’t revisit, like the start menu, and increment it by one in the room whose behavior changes based on the number of visits.

Sorry, been a bit brain dead for the last couple of days.
Will look into this.

Another thing to be aware of: only passages you link to directly are added to (history:). If you (display:) a Passage it doesn’t count.

Also: unless I’m mistaken, a passage gets counted as read after the reader has left it; i.e. if you are currently reading a passage for the first time, it will not be in (history:) at all, which means that the count you want for the purposes of any conditional statements is 0 the first time, and then 1 the second time a passage is visited, etc.

You’ve probably read over the Harlowe manual, but it’s still worth linking to: twine2.neocities.org

I’m relatively new to Twine myself, and I’ve been working with that constantly open in another tab.

This is correct – (history:) is equivalent to (and probably just prints the value of) State.pastPassageNames(), to which passages are only added after you leave.

Err no, didn’t know about that.