Hi,
I am looking to count amount of times the person passed through a passage with a certain tag in it throughout the whole story and adds +1 if passed through.
If I pass through a tag A once, it should display: You've been in A 1 time
If I pass through it twice: You've been in A 2 times
I've tried to make it work with passage history tags contains:
(if: ( (passage: (history:)'s last)'s tags contains "A") )[You've been in A once]
(else:)[No A passages]
But have no idea how to make it work for multiple passages to add +1... Can anyone help me move forward with this?
Thanks!
Comments
In Harlowe v2.x, you should be able to do something like the following to get the count of passages within the history which contain the specified tag:
Simply printing the count:
Because of the complexity of the construct, I'd suggest storing the result within a temporary variable if you'll need the value more than once within a passage. For example, using it with (if:) chain:
NOTE: Do not attempt to run that on the starting passage as the history will be empty at that point, so the construct will fail.
missing ) after argument list
I'm unsure if what you want is even possible in Harlowe v1—I know it's not possible natively, but it may be possible to access the history from JavaScript, which allows much the same thing to be done as the v2 code I provided.