Twine Sugarcube 2, How do I display a text depending on the player's previous choices?

Twine Version: 2.3.14
Story Format: Sugarcube 2.34.1

  1. How do I display a text depending on the player’s previous choices?

For example: passage A has 3 options: B, C and D. These 3 leads to passage E. I want to put different text on passage E, depending if the player reached passage E through B, C or D.

I saw in another forum that in Harlowe i could do:

(if: (history:) contains “Choice A”)[The text to show if Choice A was selected]\

or

(if: $path is “A”)[The text to show if Choice A was selected]
(else-if: $path is “B”)[The text to show if Choice B was selected]
(else:)[The text some other choice was selected]

But how do I do these in Sugarcube 2.34.1?

  1. Also, how can I display these text in a way that dosnt do line breaks? Because, for example, if a reach passage E through B, it would show me the text for choosing B, but it would leave long blank spaces where the texts for C and D would be.

Sorry for my bad english, its not my native language, I hope I made myself clear.

Please use the toolbar’s Preformatted Text (</>) option when including code examples, it makes them easier to read/copy-n-paste and stops the forum’s software from converting valid Standard quotes into invalid Typographical (curvy) quotes.

If you look in the Control Macros section of the SugarCube documentation you will see that it also has its own variations of the <<if>>, <<elseif>>, and <<else>> macros.

So if you had a set of options like the following…

Make a choice:
[[Choice A|Next Passage][$path to "A"]]
[[Choice B|Next Passage][$path to "B"]]
[[Choice C|Next Passage][$path to "C"]]

…the you can use a similar conditional structure as the Harlowe example you included…

Blah blah
<<if $path is "A">>The text to show if Choice A was selected\
<<elseif $path is "B">>The text to show if Choice B was selected\
<<else>>The text some other choice was selected\
<</if>>
More blah blah

note: I have used Line Continuation markup to supress the line-break at the end of each line of text.