Howdy, Stranger!

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

Setting passage different tags

Hi,
Currently I am looking for a certain tag in passages and counting the number of passes. What I am looking for is a way to set
somehow the tag as a code, so that I can set multiple tags for different passages.

1st tag - do not count
2nd tag - count

For example if I come from A passage with 1st tag, into passage B i get standard message, but if I come from A with 2nd tag I get different one. Is that possible? Basically I want to add additional if/else for history of passages but according to tags and mix them with passages.

Comments

  • Please help? I am stuck :pensive:
  • When asking a question you need to state the name and version of the Story Format you are using, as answers can be different for each one.

    I am going to assume you are using the default story format which is Harlowe, although without knowing which version of Twine 2 you are using I don't know if it is Harlowe v1.2.2 or v1.2.3 but the following should work in both versions.

    You can use the 'last' property of the (history:) macro to obtain the name of the previous passage, and the 'tags' property of the (passage:) macro to obtain an Array containing a list of the tags assigned to a particular passage.

    The following example consists of three passages:
    1. First passage: assign a forest to this passage.
    This passage has been assigned a ''forest'' tag.
    
    [[Show text based on tag of previous passage->Result]]
    
    [[Passage with a different tag->Second]]
    
    2. Second passage: assign a desert to this passage.
    This passage has been assigned a ''desert'' tag.
    
    [[Show text based on tag of previous passage->Result]]
    
    3. Result passage.
    (set: $tags to (passage: (history:)'s last)'s tags)\
    \
    The previous passage had the following tags: $tags
    
    (if: $tags contains "forest")[You came from the passage with a 'forest' tag.]\
    (else-if: $tags contains "desert")[You came from the passage with a 'desert' tag..]\
    (else:)[You should never see this text!]
    

    NOTES:
    a. If you are using the Harlowe 2.x story format you can change the $tags variable into a new temporary variable instead by replacing the dollar sign $ character with an underscore _ character, which will result in that Array not being saved in history.

    b. The above example could also be implemented in SugarCube but the code would be different.
Sign In or Register to comment.