0 votes
by (510 points)
My game has a chance path, where the player has a 50% chance of a fail event, has 16 sections to pass, has to pass 14 out of 16, and if the fail passage is shown for the 3rd time, it's game over (yes, I'm aware the chance of survival is 1 out of 16384). I'm pretty sure that there is a way to do this, but I'm stumped as to how to do it.

1 Answer

0 votes
by (159k points)
selected by
 
Best answer

The (history:) macro returns an Array containing the name of each Passage visited in the order that they were visited, so if the Reader has previously seen a particular passage three times then that passage's name will be in the Array three times.

You can use the (count:) macro to determine how many times a particular value is contained within an Array.

You can use code like the following within your "Failed Passage" to determine if this is the third time that passage has been shown.

(if: (count: (history:), "Failed Passage") is 2)[This is the third time you've seen this passage!]

... we check for 2 because the passage currently being show isn't in the history Array yet.

by (510 points)
Thank you! I had figured this out in part, but this is what I did in one line!
...