It looks like you're new here. If you want to get involved, click one of these buttons!
<<if visited() is 1>>You open the drawers until you find one stacked with documentation. There's a pamphlet titled [[Deep Sleep and Its Affects on the Human Mind|deepsleep]], another called <<if visited ("luckdrug")>>[[Partialiterfortuna|luckdrug2]]<<else>> [[Partialiterfortuna|luckdrug]]<</if>>, and one on [[Handling Isolation in Deep Space.|deepspace]] Return to [[room.|lab]] <<else>>There's a pamphlet titled [[Deep Sleep and Its Affects on the Human Mind|deepsleep]], another called [[Partialiterfortuna|luckdrug2]], and one on [[Handling Isolation in Deep Space.|deepspace]] Return to [[room.|lab]]<</if>>
Comments
What code are you using to send the player to the "You've already read this." passage and more importantly what code are you using to return the player back to the passage containing the above example?
eg. If your above example is in a passage named "The Room" are you using code like either of the following to return from the passage containing the "You've already read this." message or are you doing something else?
I return the player on a timer.
1. The passage that contains a modified version of your example, you did not state what this passage was called so I will name it search.
note: I formatted the above example with extra line-breaks to make it easier to see the different conditional sections, then used the backslash character to remove the extra line-breaks in the output.
2. The luckdrug passage, which contains some text about reading and a time based goto.
3. The luckdrug2 passage, which contains your "You've already read this." message and a time based goto.
So that I can at least try and get my head around <<if>> macros, can I ask a few questions.
In the main block of code (the first) you put a closing <</if>> at the end of the first sentence, and then the rest of it afterwards. Is this instead of using an <<else>> ?
I always thought an <<if visited() is 1>> always had to be followed by an <<else>>, because in English what we're saying is If the player is visiting for the first time say [this], but if he's re-visiting say [this]
I know there's an <<else>> in there, but that one's handling which passage they should be sent to.
What I don't understand is how the game knows to read beyond the closing <</if>> for a first visit??
I dunno if that makes sense?
note: the first part of the following explanation ignores the fact you have a markup link that needs to conditional change which passage it targets. I will cover that issue in the second part.
Part A. The output of your example can be basically broken down into two sections:
1. The Static section:
This section of text is displayed to the reader every time they visit this passage and it does not change. This means that you don't need to use an <<if>>, <<else-if>> or <<else>> macro to cause it to appear in the output.
2. The Conditional section:
This section of text is only displayed to the reader if the related condition is true, because there is no alternative text to display instead you don't need an <<else-if>> or <<else>> macro.
A simplified example would look something like the following:
Part B. A link that changes it's target passage:
In your example the Static section also include a markup link which conditionally targeted one of two different passages, there are two ways this could be handled.
1. Conditionally change which markup link was added to the output:
You used an <<if>> macro to output one of the possible markup links if the related condition was true, and you used an <<else>> macro to output the second if the related condition was false.
Using this method required changing the Static section so that a part of it is now conditional.
2. Use a (temporary) variable as the conditional markup link's target:
Using this method does not require the Static section to change but it does add extra complexity between the Conditional section and the Static section. warning: Due to a limitation of Twine 2.0.11 the above example will cause an invalid passage named _target to be automatically created, you will need to delete the _target passage.