Is there a better way to do OR/NAND?

Discussion in 'Authors' Hangout' started by RejectTed, Feb 24, 2022.

  1. RejectTed

    RejectTed Really Experienced

    I'm fiddling around with game mode and have a bit where the I want something to be displayed if two things are true and something else if one or both are false. Right now I have something like:
    I don't really like this. It feels a bit complicated, and I'm kinda worried I'll forget to edit one version of text 2 if I need to make changes. I guess writing the same text twice just goes against my (admittedly limited) programming experience. Is there a better way? I know if you're doing something similar with chapters you can use link chapters to avoid duplicate chapters.
     
  2. insertnamehere

    insertnamehere Really Really Experienced

    There is currently no better solution.
     
    RejectTed likes this.
  3. gene.sis

    gene.sis CHYOA Guru

    I second that.


    Well, that approach can also be used to precalculate the value before opening the chapter.
    So you would need 4 link chapters per chapter option that leads to the chapter.

    {if precalculated = true} text 1 {else} text 2 {endif}


    If the boolean values of both variables can only be switched (true to false and false to true,) you could also use a numerical variable to precalculate the option.
    (This approach doesn't need any additional chapters.)
    If either of the variables is switched from false to true, additionally add the score change
    precalculated + 1
    If either of the variables is switched from true to false, additionally add the score change
    precalculated - 1

    {if precalculated > 1} text 1 {else} text 2 {endif}
     
    RejectTed and insertnamehere like this.
  4. RejectTed

    RejectTed Really Experienced

    Yeah, I figured there wasn't. Thanks though.
    These are a bit too much work for the current job, but I'll keep them in mindfor the future.
     
    gene.sis likes this.