Is there a macro I can use in Twine 2 to display an option for an action if they have read a particular passage.
For example, in one passage if they choose to pick up a candle, that leads to a confirmation passage with a bit of text about what happens when the candle is collected. How can I macro in an if statement in another passage to light the candle if they've seen the confirmation passage.
If that is a bit vague, or made little sense:
If one passage has been visited, how can I add an option in another passage to display ONLY if they've been to the other passage?
Thanks!
Comments
For this you would use the (history:) macro.
Using the example you provided, if your confirmation passage of the candle was called "Candle Confirmation", and your other passage (where you want them to go if they have been to Candle Confirmation) is called "Another Passage", then you would use the (if:) statement and (goto:) macro as follows:
I hope that makes sense and is what you are looking for.
Thanks for your reply!
That's almost what I'm looking for. I'd like the option to do another action to display, rather than for it to just go to the next passage, if that's possible?
Thanks again!
Yes, it is. Whatever action you want it to do, you put it within the [hook].
If you want it to just display some text:
If you want to set a variable to something do it like this:
OR if you want the value of the variable to be a number:
It works the same as any (if:) statement.
Perhaps if you share what action you want we could offer you a specific answer.
That's a massive help!
Cheers!
What if I wanted some text to be displayed based on a previous button choice and other text to be displayed for choosing the same button but with a different title, i.e.
Candle Confirmation
This text is different->Candle Confirmation
In the case above, how would I indicate with the
(if: (history:) contains "This text is different") ?
It doesn't work because it's not actually it's own passage, it's only the title to direct to the same passage.
How could I do that?
You can use a $variable to remember if something has occurred.
a. At the start of your story initialize the $variable to a default value like so:
note: the variable can be named whatever makes sense based on what it is doing. b. Update the $variable if the correct link is selected like so:
note: this is known a setter link, because the link sets a $variable. c. A safer way to do the above is to assign a value to the $variable for both links:
I'd like it to be a normal button and direct the player to a new passage. But depending on which button they choose, different text will start off the passage - followed by the remained of the text that is displayed for either choice.
So at the top of the said passage, I would need a way to display only the text that should be displayed based on the previous choice.
If that is confusing here is an example:
{
Want some milk?
No, milk is gross.
No, thanks. I'm allergic->No, milk is gross.
In the passage - "No, milk is gross."
(If: No, milk is gross) All right, milk isn't to everyone liking.
(if: No, thanks. I'm allergic.) Oh, okay. I didn't know you were allergic.
But cookies are amazing with milk. At least I think so.
}
That's pseudo code for what I want I fathom happening.
How would I do something like that?
a. Place the following in one of your passages: b. Place the following in a passage named No, milk is gross.
Harlowe does not have a built-in button macro.
One last thing I noticed.
The line in the story map view no longer appears between the two passages. But when I click on either link, it directs me to the passage normally.
Is that supposed to happen when writing the code this way?