Show player history of choices

Please specify version and format if asking for help, or apply optional tags above:
Twine Version: 2.3.9
Story Format: Suguarcube 2.31.1

Heya everyone! I was just looking for some help. At the end of the twine I’m creating I want to show the player a history of choices they’ve made. The idea for the twine is that players go through a dance generator to create their own unique dance routine.

An example of what I want at the end is

Your dance routine has these steps
1 - Nod your head
2 - Flex your arms
3 - Tap your toes
4- Spin around

Each of these dance steps are the names of passages audiences have clicked on which then leads to the next passage ( Hopefully that makes sense?)

Hopefully you can help!

Here’s the simple version of what you want:

<<for _i = 0; _i < State.length; _i++>>
	<<= State.index(_i).title>>

That will show a list of the titles of all passages you’ve visited that are within the game’s history.

You may need to modify that to filter out any titles that you don’t want displayed, but that should give you the general idea. (For details see State.length, State.index(), and the Story API.)

Hope that helps! :grinning:

This is so helpful! Thak you so much!

Hey @HiEv

For some reason I can’t seem to make it work. What would it be like if it was to show the player the last 7 passages they’ve visted? Been trying to do it for a while and It doesn’t seem to be working!

What do you mean when you say you can’t seem to make it work? What exactly isn’t working? Are you getting an error? What does your code look like?

You’ll need to provide more information if you want people to be able to help.

If you want to limit it to the last seven passages, then it would just be a slight modification like this:

<<for _i = (State.length - 7).clamp(0, Infinity); _i < State.length; _i++>>
	<<= State.index(_i).title>>

Hope that helps! :grinning:

As a note. By using State.size you will also get undone—i.e., rolled back—moments. If you want to guarantee that only moments that are still current are shown, then you should use State.length instead.

Good point. I’ve fixed the above code snippets.