A way to get true if the variable doesn't exist

Discussion in 'Suggestions' started by RejectTed, Sep 16, 2019.

  1. RejectTed

    RejectTed Really Experienced

    Right now, if a condition branch or if statement checks a variable that hasn't been created, it will always return false, but there are times you want it to be true. For exvmple, lingerie may have been given in a different chapter and you want to see if the main charcter doesn't have it.

    One solution is to have something like {if lingerie=notexist}. Or there could be some way to set it to default to true if there is an error.
     
    Greyrock likes this.
  2. gene.sis

    gene.sis CHYOA Guru

    Well, you can check for that in if statements. (Though not that comfortable)
    {if lingerie=false}[leave blank if you don't need to handle false]{else}[enter her what happens if lingerie is true or if it is not set]{endif}

    It's just not possible in conditions.
     
    RejectTed likes this.
  3. dingsdongs

    dingsdongs Really Really Experienced

    Suggestion for another workaround: Create it always.

    Example:
    Create a variable "lingerie_given" = "False" at the beginning of the story.
    Set the variable "lingerie_given" = "True" in the chapter you talked about.

    Now you can always check for it.
     
    RejectTed and gene.sis like this.
  4. RejectTed

    RejectTed Really Experienced

    Unfortunately, that's not possible if you aren't the story owner or editor.
     
    Greyrock and gene.sis like this.
  5. Greyrock

    Greyrock Really Experienced

    This is occasionally a problem for a game even when you are the owner. If you decide to add branches and variables to old chapters, players that already have saved games beyond those branches wont have those variables defined.

    Later in the story I’d LOVE to be able to check if a variable is undefined in a conditional chapter. As it is now, I create a fallback chapter as link of last resort. Players should ignore it unless it is the only chapter they can access. It will update the missing variable with a default value. It’s not elegant.
     
  6. gene.sis

    gene.sis CHYOA Guru

    Right now, you could work around that by using a variable that determines the "version" of the user's savegame.
    You set a numerical variable in the introduction chapter, starting value = 1.
    If you later add something that needs a higher "version", you can show a small message to the reader in certain branching chapters or in chapters that precede a chapter the change is needed for.
    Sth. like
    Code:
    {if version > 1}{else}There have been changes to the game mechanics that aren't compatible with your savegame version. For the full experience, please reset your savegame.{endif}
    After adding that line, edit the introduction and set "version" to 2

    If you don't need backward compatibility, you could also use the more intuitive version:
    Code:
    {if version < 2}There have been changes to the game mechanics that aren't compatible with your savegame version. For the full experience, please reset your savegame.{endif}
     
    insertnamehere and Greyrock like this.