I am using Twine 2.3 and Sugarcube 2.29
I want to show the player some kind of introduction when he first visit a passage. So i used hasVisited() function, here is my code
<div data-theme-scrollable="true"><<if hasVisited("dungeon")>>
but somehow the introduction part never gets executed i don’t know what i am missing .I even used not hasVisited(), <<if lastVisited(“dungeon”) is 0>> nothing worked for me.Can anyone point out what i am missing.Thank you.
I don’t know why my code did not displayed there.Here is my code
FYI - You have to use the preformatted text icon
</> to wrap around your code if you want it to be visible. For multiple lines of code you can do three backticks (on the
~ key) on a line by itself, then the code, then three more backticks on a line by itself to end the code section.
Not a Twine expert, but shouldn’t there be something inside <>?
There probably was when Prasanth originally wrote that. However, if you type in
<<xyz>>, without putting it inside of preformatted text markers, this forum displays it like this: <>
Regarding your code, it should be done like this instead:
<<if hasVisited("Passage Name")>>
<<endif>> format has been depreciated in favor of the
<</if>> format, instead of “fancy quotes” standard double or single quote markers should be used to indicate the content is a string, and you should use double angle brackets around macro code. Single angle brackets should only be used for HTML code.
Anyways, Prasanth will need to repost his code inside of preformatted text markers before we can figure out what’s going on there.
Yeah…someone who moderates the forum probably should have noticed that or something…
I edited his message to include the back ticks. I didn’t even think to open the message and look at the raw text in there.
Thanks for correcting me. I work in AXMA Story Maker which is based on the original and simplified version of Twine which is why my psuedo-code was mainly deprecated forms.
OK, now that I can see your code, I think I understand the problem.
If you’re using your above code within the “dungeon” passage, then
hasVisited("dungeon") will be true, because you’re currently in that passage, thus it has been visited.
If you want some text to only show the first time you enter a passage, you can do this:
<<if visited() == 1>>
First visit text.
Text shown in subsequent visits.
In the above, the visited() function checks to see how many times you’ve visited the current passage (including this visit), and if it’s 1, then it shows the text for the first visit, otherwise it shows the alternate text.
Hope that helps!