[Twine Sugarcube] something like Harlowe's (history:) macro?

Hello!
I’m new to both Twine and this forum! Since I cannot find a question/answer when googling I decided to make an account in hope that someone could provide an easy answer. :slight_smile: Maybe I’m just tired.

I had to change the story format from Harlowe to Sugarcube for my story since I’d like to do more with audio etc. later. However, in my game, there was a passage previously containing (if: (history:) contains “passagename”)[…] and so on - basically, a certain piece of text was displayed ONLY if the player had previously visited a certain (previous) passage. If not, the passage would just show the following text, still relevant independent of previous passages.

My question is: how do I do this exact same thing with sugarcube? I feel like the answer should be simple, but right now I just feel lost. Hopefully someone here can help.

SugarCube has a number of functions you can use to determine which Passages have previously been ‘visited’.

For the use-case you mention in your question I suggest using the hasVisited() function. The function’s documentation includes examples on how to use it in combination with the <<if>> macro.

Hey @Greyelf, thanks for your answer! I did try that, but it didn’t work so I think I’m still doing something wrong.

I wrote like this:

<<if hasVisited(“Let her in”)>>“What is your name, Miss…?”
“Lizzy,” answered the woman.<< /if >>

Is “Let her in” the name of the current passage? If so, then you’ll have to do things slightly differently using the visited() function, like this:

<<if visited() === 1>>“What is your name, Miss…?”
“Lizzy,” answered the woman.<</if>>

That should work properly now if that was the problem.

Hope that helps! :slight_smile:

P.S. If you want to display code properly in this forum you’ll need to use the “code block” button (the one that looks like </>) to mark that text as code.

Sorry, “Let her in” is the past passage, the one that serves as a condition as to whether display that certain string of text in the current passage (where I want to place the code). Does that make it more clear?

@cs
The following 3 passage example is written in TWEE Notation, it demonstrates that using the hasVisited() function should work successfully in the situation you have described.

:: Start
[[See "Result" without visiting "Let her in"|Result]]
[[See "Result" after visiting "Let her in"|Let her in]]

:: Let her in
The "Let her in" passage.
[[See "Result"|Result]]

:: Result
The "Result" passage.
<<if hasVisited("Let her in")>>You visited the "Let her in" passage.<</if>>

If you use the 1st link within the Start passage then the conditional message within the Result passage will not be shown, on the other hand if you use the 2nd link to travel to the Result passage via the Let her in passage then the condition message will be shown.

I’m sorry, I don’t really understand because newbie. :frowning: I think I’m getting confused and mixing up what we’re saying here.

Let’s call the text I want to display “conditionaltexttodisplay”, yeah?

And then let’s name the passages “Let her in” for the one the player MIGHT have visited before (the one I want to check) or not.

The passage in question where I want to use this code could be named “checkingpassage”. IF “Let her in” has been visited previously I want “checkingpassage” to display its original text AS WELL as “conditionaltexttodisplay”. If not, ONLY "checkingpassage"s original text should be shown.

The two passages are NOT connected directly after each other. The player can take lots of different ways, and therefore they do not have a direct link between them.

@Greyelf could you explain it again with these parameters so that I understand? :sweat_smile: Where is “start” in this context? Is it the game’s very first passage or the Javascript sheet?

Thanks for your patience!

Greyelf wasn’t saying that that was anything you should put verbatim within your own game. He was just trying to give a simple example of how it could work if “Start”, “Let her in”, and “Result” were names of the only three passages in that example game, and “Start” was the name of the starting passage.

To answer your question, within the “checkingpassage” passage you’d put:

Original text.
<<if hasVisited("Let her in")>>
conditionaltexttodisplay
<</if>>

Upon visiting that passage, the user would see “Original text.” and, if they had previously visited the “Let her in” passage, then it would display “conditionaltexttodisplay” as well. (NOTE: That code will only trigger if the name of a previously visited passage was “Let her in”. It would not trigger if you had visited passages named “Let Her In” or “let her in” instead, since the capitalization is different. Names like this are case-sensitive, meaning that the upper- and lowercase letters must match.)

If that isn’t working the way you want, then you’ll have to explain what’s wrong more clearly, because otherwise it appears like that should do exactly what you want.

It looks like you tried that earlier, but all you said was, “it didn’t work,” without specifying in what way it failed, so you’ll have to be more specific.

Hope that helps! :slight_smile: