Uhh, just copy exactly what I put. <<include>>
only takes one argument and _passageName
is literally that argument.
Let me explain a little better…
Let’s say you have the first passage and second passage
:: passage 1
The 1st passage text
:: passage 2
The 2nd passage text
And the footer
:: PassageFooter
<<if passage() != "log">>
[[passage 1]]
[[passage 2]]
[[passage 3]]
[[log]]
<<set $passagesVisited.push(passage())>>
<</if>>
Note that this <<if>>
statement checks conditions. So in this case, IF passage()
[i.e. the passage name] !=
[<-- this syntax means “is not”] "log"
then include the code within the IF block (that’s anything between <<if>>
and its closing tag, <</if>>
. Because neither the text “passage 1” or “passage 2” are the same as the text “log”, the stuff within the <<if>>
blocks shows up. Please look up what if statements are in code to find more explanation.
In the actual code of the page, Sugarcube will interpret everything here so passage 1 and passage 2 look like this. Do not copy this code, the code I put above does exactly the same thing.
:: passage 1
The 1st passage text
[[passage 1]]
[[passage 2]]
[[passage 3]]
[[log]]
<<set $passagesVisited.push(passage())>>
:: passage 2
The 2nd passage text
[[passage 1]]
[[passage 2]]
[[passage 3]]
[[log]]
<<set $passagesVisited.push(passage())>>
This means the links and the <<set>>
code show up in both passages.
passage()
gets the name of the passage you’re on.
So what it ACTUALLY looks like in the code is essentially this:
:: passage 1
The 1st passage text
[[passage 1]]
[[passage 2]]
[[passage 3]]
[[log]]
<<set $passagesVisited.push("passage 1")>>
:: passage 2
The 2nd passage text
[[passage 1]]
[[passage 2]]
[[passage 3]]
[[log]]
<<set $passagesVisited.push("passage 2")>>
$passagesVisited
is an array. Please look up what a JavaScript array is. Twine is just simplified JavaScript.
If you visit both passages in order, then the inside of $passagesVisited
will look like this: ["passage 1", "passage 2"]
Now, the log passage.
:: log
<<for _passageName range $passagesVisited>>\
<<include _passageName>>\
<</for>>
Please look up what a JavaScript for loop is!! The <<for>>
loop will run the <<include>>
text as many times as there are values in the $passagesVisited
array, sticking the values in the code provided. Since the array has the values “passage 1” and “passage 2” in it, it will run 2 times, with “passage 1” first and “passage 2” second.
This is equivalent to:
:: log
<<include "passage 1">>
<<include "passage 2">>
If you don’t have basic programming knowledge of arrays, variables, if conditions, and for loops I’m not sure how to explain this any better.
ETA:
because <<include>>
just includes the contents of the passage with that name, it means that :: log ACTUALLY looks like this
:: log
The 1st passage text
The 2nd passage text