Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

"Tags of last visited passage"

Hi. A question about Harlowe.

So, if I want to make mechanic that checks what tags last visited page has... how do I do it? Is it possible?

I'm having a Player Appearance passage. It can be opened any time from the sidebar. Now, I'd like to make it change according where do you open it. For example, it would add some descriptions if you open it from passage with tag "forest."

Also, a related question. Is it possible to make (goto:) move you to last passage that contained certain tag? For example, forcing player to go back to the last "forest" tag they visited.

Comments

  • You can use the (passage:) macro to access the tags of the specified passage, and you can use the (history: ) macro to obtain the name of the previous passage.

    Combining these two macros will give you access to the tags of the previous passage:
    The current passage's tags are:
    (print: (passage:)'s tags)
    
    The previous passage's tags were:
    (print: (passage: (history:)'s last)'s tags)
    
    You can further combine the above with an (if:) macro and the Array data contains operator to check if the previous passage contained the "forest" tag:
    Check if the previous passage contains the forest tag:
    (if: (passage: (history:)'s last)'s tags contains "forest")[Found forest]
    (else:)[Did not find forest]
    
  • edited April 2016
    Thanks, that cleared a bit.

    Can you search passages from history by tags? For example, making (link-goto:) to last passage with certain tag?

    Also, can I make sentence that's basically inverted contains, like "if array does not contain x)?
  • Matoro wrote: »
    Also, can I make sentence that's basically inverted contains, like "if array does not contain x)?
    Try using a not operator before the original condition, you will need to wrap the original condition in parenthesise like so:
    Check if the previous passage does not contain the forest tag:
    (if: not ( (passage: (history:)'s last)'s tags contains "forest") )[Forest not found]
    (else:)[Found forest]
    
    Matoro wrote: »
    Can you search passages from history by tags? For example, making (link-goto:) to last passage with certain tag?
    There is no built-in macro for this, so you would need to loop each Passage Name in the array returned by (history:) and check if that passage's tags contained the one you are looking for. There is currently no for macro so you would need to use a (live:) macro to simulate one.
    One thing to remember is that a particular Passage Name can appear in the (history:) array more than once.
Sign In or Register to comment.