Having trouble with if/elseif statement

I’m having trouble with the if and else if statement

The idea was that, based on a previous choice you could get a different outcome (in this case meeting a certain npc) but for some reason, no matter which variable is true, it only shows the first “if”

My code looks like this:

*if (arr_aft = true)
    a man enters the office
   *set marc_met true

Narrative text

        If we're done here, I have to go now.
        "If we're done here, I have to go now.  
       " Sorry, but I really need to go."
        "Sorry, but I really need to go."
*elseif (arr_laft = true)
    a man enters the office
    *set marc_met true
*elseif (arr_eve = true)
    a woman enters the office
    *set jada_met true

Why is there a whole choiceblock between your *if statement and the *elseif ones? Was it supposed to be inside the first indent? I’m not really sure what’s the goal here.

It was supposed to be a sub scene with sub choices (that would then lead back to the main narrative). Should I indent it differently or is that something I just can’t do?

I’m not sure what you mean by “sub scene” here. Do you wish this choice (which for some reason has repeating options?) to appear only if the first condition is met, or to appear regardless of which variable is true?

If the former, just put it inside of the indent block. If the latter, just put outside of the *if statement altogether. You can’t just shove it between two parts of the conditional, it will just break the whole thing.

1 Like

Thank you. I actually fixed it, though I gotta be honest I have no idea how, I guess if it works it works? :sweat:

Your problem was the indents. “Narrative text” was indented to the same level as the if/elseif, so it interrupts the code flow. Choicescript wasn’t reading your code as an attempt at an if/elseif block, but as an isolated *if statement, followed by “Narrative text” and a new choice block. It was never “seeing” the elseifs, because the other code block was in the way.

If you indent “Narrative text” to the same level as *set marc_met true (and adjust the indents for the following choices accordingly) then you should have an if/elseif block that works correctly, with a choice block inside it that only triggers if arr_aft = true.


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