I’m writing my first interactive story in Twine and I need a little help.
I have three possible endings to my story, and each one could be triggered if the player chooses two or more conversation paths along the way. In the story one ending sees the protagonist’s mom coming to their rescue, the second their friend coming to their rescue, and the third is that no one does. If the player chooses two or more of conversation paths with their mom, that will trigger the Mom ending, same with the friend. But I’m not quite sure how to program this. I’m thinking this may involve a boolean code, but I don’t really know how to tag the passages and to make sure that each ending fits the requirement of two or more triggering passages.
So if the times talked to friend and times talked to mom are equal and I want that condition to lead to RescuedbyMom, could I use something like this in the final sequence (along with the friend, mom and no rescue conditions):
<<elseif $timesTalkedToFriend >== 2 and $timestalkedtomom >== 2 >>
[[RescuedByMom]]
So in total it would look like this:
<<if $timesTalkedToMom >== 2>>
[[RescuedByMom]]
<<elseif $timesTalkedToFriend >== 2>>
[[RescuedByFriend]]
<<elseif $timesTalkedToFriend >== 2 and $timesTalkedToMom >== 2 >>
[[RescuedByMom]]
<>
[[NotRescued]]
<>
*Note for some reason the else and if at the end are not showing up properly, but they are in there!
Sorry about the “>==” thing instead of “>=”. For some reason I make that mistake when writing posts, but not when writing code.
Also, you should be aware that the <<if>> macro only triggers the first chunk of code which has a conditional with a “truthy” value. (The values null, undefined, 0, NaN (Not a Number), "" (an empty string), and false are all “falsy” values, all other values are “truthy” values.)
This means that you won’t need the:
<<elseif $timesTalkedToFriend >= 2 and $timesTalkedToMom >= 2 >>
part, because the
<<if $timesTalkedToMom >= 2>>
part would’ve already triggered in that case, since it comes first.
Hope that helps!
P.S. If you’re going to post code in this forum you should wrap it within a “preformatted text” block (use the </> button), otherwise the forum has a habit of eating macros (see in your code where the <<else>> and <</if>> look like “<>”).