*if...*else not working correctly

I have encountered an issue with an *if…*else block not working inside a much larger file where other *if…*else commands are working.

During testing, I discovered that a block seemed to be getting skipped. I worked out that it doesn’t get skipped if I don’t use any *else statements.

I don’t understand why this particular block is having problems, but other similar blocks elsewhere in my code are fine.

I have implicit flow control on if that matters. I have confirmed that the two variables used in the *ifs are correctly defined either in the startup.txt file or in the current scene file (and not double-defined or anything). I don’t get any errors, the block is just ignored.

This how I’d like to write the code, but it’s not working, as shown in the first screenshot. Note that the “Separate? ${separate}” line is there for debugging purposes.

*comment Narrowing Target <section>
*comment Narrowing Target - VC <sub-section>
*comment You can get here without referencing specific evidence
*label victorCrawford
*set narrowingTarget true
Separate? ${separate}

*comment Update time remaining <review>
*comment You decided to investigate separately
*comment This block seems to be getting skipped entirely <review>
*if (separate)
  *comment Whitney is offended by you
  *if WCrelScore < 4
    "Alright, Sonnia and I will investigate together now," Whitney tells you. "You're free to do whatever you want."
    *goto investigateSeparately
  *comment Whitney is annoyed with you
  *comment An else here doesn't seem to work <review>
  *comment *if WCrelScore >= 4
    "Alright," Whitney says. "We can split up here if you still want to do that."
      #Investigate with Whitney and Sonnia.
        "I've changed my mind," you respond. "I'd like to continue the investigation together."
        "Oh good," Whitney smiles. "Glad to hear it."
        *set WCshortTerm ""
        *goto dramaticRetelling
      #Investigate on your own.
        "Sure, we'll leave you be."
        *goto investigateSeparately
*comment You decided to continue to investigate together
*comment An else here doesn't seem to work <review>
*comment *if (separate = false)
  *comment Whitney is offended by you
  *if WCrelScore < 4
    *goto boringRetelling
  *comment Whitney is happy
  *comment An else here doesn't seem to work <review>
  *comment *if WCrelScore >= 4
    *goto dramaticRetelling

If I replace all of the *else commands with *if commands that effectively do the same thing, it works, as shown in the second screenshot.

Issue occurs:

Issue does not occur:

That’s weird af, I don’t see anything wrong with it, but just to be sure, have you checked you are working with the actual files that are being tested?
I remember one time that I modified a file and save it and it didn’t affected the test at all, until I realize it was a file in another folder :man_facepalming:

I’ve had a similar issue before, I’d suggest changing the second if to elseif and then ordering them by priority.

I am just wondering about the separate variable. You seem to have it both as a ${separate} and as *if (separate) could that be the issue? Do you have a *set separate true somewhere?

I’ve just double checked and the separate variable is declared as a boolean and treated as such throughout the entire file, never as any other type. I’m only displaying its value here for the purpose of confirming that it does indeed have a value of true at that particular point in time - meaning the first half of the block should be triggering.

Thanks everyone for the responses so far. I will make the recommended changes to get around the issue, but I’d prefer to figure it out rather than to have to check all future *if…*else blocks for this problem.

I’m not in a place to check this myself, but have you tried indenting the three *comment lines just above the *elses, so they’re not at the same level as the *if/*else?

I’m just wondering if the *else only works if the most recent command at the same indent level above it is an *if. The comments might be getting in the way?


I ran into the same issue. Your *comments are breaking your *elses.

That solved it! Thank you very much, glad to know what the issue is. I’ll go back through my code and make sure I haven’t made the same mistake anywhere else.

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.