Howdy, Stranger!

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

Unclear how to use (if: (history:) contains "Passage") for multiple options.

Hi folks! I've been wanting to get into using Twine for a while and have finally made a concerted effort to create something on it. I feel pretty confident with a lot of the functions, but I can't quite get my head around the (if: (history:) contains "Passage") option to display otherwise hidden text.

Specifically: I'm writing something involving a medical examiner, and I'd like to have an option present itself for him to 'make a verdict' but only after he's examined certain parts of a body (eg head, torso, right arm, left leg) - the order's not important, just as long as those options/pages have been explored/visited. How can I do this?

Thanks for any help!

Comments

  • I prefer not to use the history functions too much. For specific things like this, you can just (set:) a variable in each passage and then test if the player has uncovered all variables with something like

    (if: $head and $torso and $feet)[[[Make a Verdict]]]
  • While Claretta's answer works, it's pretty simple to use (history:) for this.
    (if: (history:) contains "Examine Head" and "Examine Torso" and "Examine Feet")[[[Make a Verdict]]]
    Note the triple [] pairs; the outer [] are the hook for the (if:) macro, and the inner [[]] are the passage link markers. It displays oddly in my Twine passage map - the system seems to expect the third [ to be part of the passage name when there are no spaces - but when actually playing it through, it processes it correctly.

    If you're concerned about that, you can easily just compress the extra whitespace and do it like this.
    {(if: (history:) contains "Examine Head" and "Examine Torso" and "Examine Feet")[
    [[Make a Verdict]]
    ]}
  • [quote]
    (if: (history:) contains "Examine Head" and "Examine Torso" and "Examine Feet")[[[Make a Verdict]]]


    This is only checking if "Examine Head" is in (history:) and is just checking if the "Examine Torso" and "Examine Feet" string literals are not equal to a false value.

    Test code: If you visit the "Examine Head" passage and then run the check you will see the link but the Torso and Feet tests wont show related text.

    (if: (history:) contains "Examine Head" and "Examine Torso" and "Examine Feet")[[[Make a Verdict]]]

    (if: (history:) contains "Examine Head")[Examine Head was found in history]
    (if: (history:) contains "Examine Torso")[Examine Torso was found in history]
    (if: (history:) contains "Examine Feet")[Examine Feet was found in history]
    Try the following:

    (if: (history:) contains "Examine Head" and (history:) contains "Examine Torso" and (history:) contains "Examine Feet")[[[Make a Verdict]]]
    note: the above is not efficient because it searches through the full passage history three times.
  • greyelf wrote:

    This is only checking if "Examine Head" is in (history:) and is just checking if the "Examine Torso" and "Examine Feet" string literals are not equal to a false value.


    Dang it. I specifically tried testing to see if that was the case and I only just realized after going back and looking at it that I had the wrong check first. Now I feel dumb.

  • Hi folks, thanks a lot for your input! I've used InspectorCaracal's suggestion, and it works, although when Make a Verdict appears as a choice, it's underlined and won't link to the (now existing) passage... Do I maybe need to put some other code in somewhere else or something...?
  • [quote author=Rev.Austin link=topic=2607.msg8498#msg8498 date=1428990390]
    Hi folks, thanks a lot for your input! I've used InspectorCaracal's suggestion, and it works, although when Make a Verdict appears as a choice, it's underlined and won't link to the (now existing) passage... Do I maybe need to put some other code in somewhere else or something...?


    When you say InspectorCaracal's suggestion do you mean:

    a: The version with a logic error:
    (if: (history:) contains "Examine Head" and "Examine Torso" and "Examine Feet")[[[Make a Verdict]]]

    b. The version without a logic error:
    (if: (history:) contains "Examine Head" and (history:) contains "Examine Torso" and (history:) contains "Examine Feet")[[[Make a Verdict]]]
    The [[Make a Verdict]] markup link in both of the above example creates a link with text of Make a Verdict that sends you to a passage named Make a Verdict, note that passage names are case sensitive. To test that your markup link is correct make a copy of the link without the (if:) macro and it should work.
  • All these shenanigans are why I prefer to stick to variables. :P
Sign In or Register to comment.