How to display previous chosen links but keep playing?

Hi,
I’m still new to Twine and am looking for some help.
I’m try to create a poem selector;
It is basically a series of links which picks the lines of the poem that you see.
I’ve linked it into a loop so that it returns to the start again once a line is completed.

However I was hoping to pick a line and then still display that 1st line and return to the loop on the 2nd line.
That way each time you go around the loop you add in a new line.
And so the poem accumulates to a maximum of 10 lines.

Is this possible?
Hopefully this makes sense, thanks in advance for your help.
Elister

1 Like

Create a global variable for the poem, like
<<set $poem = "">>

It can be empty at the start, then on each link, you make the choice and add it’s name to the poem with a new line, like

[[Roses are Red|Second Line][$poem += "Roses are red"<br>]]
[[Violets are Blue|Second Line][$poem += "Violets are blue"<br>]]

And so on and so forth, then on the “Second Line” passage, you just display $poem at the top of the page by literally just writing $poem on it.

Note: += Means concatenate, it adds the value you put to the previous values, for example, if $poem = "Roses are Red<br>", then $poem += "You should be dead" will result in $poem = "Roses are red<br>You should be dead"

Relevant bits of documentation:
https://www.motoslave.net/sugarcube/2/docs/#markup-naked-variable
https://www.motoslave.net/sugarcube/2/docs/#markup-link
https://www.motoslave.net/sugarcube/2/docs/#macros-macro-set

1 Like

Thanks for this. I’ll give it a go!
:grinning:

1 Like