Howdy, Stranger!

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

Is there a shorter way? (harlowe, multiple variable conditions)

I somehow ended with this long string of conditions, and thought there must be a shorter way that is escaping to me. None of the ways I tried to shorten it worked.

This is a text that has to show up every five "days" in a certain page the players visit a lot during a chapter of the story.
(if: $day is 5 and $knowsplay is "yes" and $rehearsal < 3 or $day is 10 and $knowsplay is "yes" and $rehearsal < 3 or $day is 15 and $knowsplay is "yes" and $rehearsal < 3 or $day is 20 and $knowsplay is "yes" and $rehearsal < 3)

Comments

  • Well, 1.4 had module arithmeric - if Harlowe has it you could probably do:
    (if: $day % 5 is 0 and $knowsplay is "yes" and $rehearsal < 3)
    

    At the very least you could do:

    [code}(if: $knowsplay is "yes" and $rehearsal < 3)
    (if $day is 5 or $day is 10 or $day is 15 or $day is 20)[/code]

    Note sure how to express in Harlowe a more complex solution like an array of extra texts for each day and simply output the text (could be blank) if the first three conditions are met.
  • edited June 2015
    mykael wrote: »
    Note sure how to express in Harlowe a more complex solution like an array of extra texts for each day and simply output the text (could be blank) if the first three conditions are met.

    The first part of the conditions: (if: $knowsplay is "yes" and $rehearsal < 3) is ignored, and only the second part is controlling if the text shows or not.

    Edit: A friend suggested this, and it worked:
    (if: $var1 is "yes" and $var2 < 3)[(if: $var3 is 5 or it is 10 or it is 15 or it is 20)[text on page]]
    

    I figured out people would want to see a solution if they ever have this same problem.
  • edited July 2015
    Hello Rafe,

    Given that your text needs to appear every 5 days, if you want to be able to go on forever, it would be much, much easier and efficient to use a simple modulo:
    (if: $var1 is "yes" and $var2 <3 and $day % 5 is 0)[text on page]
    

    With this code, you can have any number of days in your story, the [text on page] will always appear when 5 days have passed.
Sign In or Register to comment.