Falling out of a choice statement

Hm. Hey. Hey. Mind if I use this old discussion? I don’t want to start a new one because the title matches what I’m stuck on anyway. I’ve been struggling with the code for a few hours now and it won’t let me into the next scene, and I’m not sure what I’m actually doing wrong. I tried using *gosub instead of *goto. I’ve tried shifting *if, I’ve tried having everything *if, I’ve tried *else, then I’m trying *elseif. I’ve added *finis, I’ve put them away again. I’ve renamed the *label and the scene folder. I don’t know anymore. Anyone see where the error is?

Basically, my intention is that if a player makes his MC more intellectual he’ll go into a different scene than if he makes a MC more focused on physical strength.

Thanks to anyone who looks at this.

    *if (intelligence > 9)
      *goto_scene linam_know1 firstencounterlinam
    *elseif (charisma > 9)
      *goto_scene linam_know1 firstencounterlinam
    *elseif (speed > 9)
      *goto_scene linam_know1 firstencounterlinam
    *elseif (strength > 9)
      *goto_scene cailus_know1 firstencountercailus
    *elseif (endurance > 9)
      *goto_scene linam_know1 firstencountercailus

Your indents are off. All of your *elseif statements should line up with the original *if.

1 Like

Hm. That’s not it. It’s showing up fine in the IDE. Just to be sure, I tried aligning it, but there was no change. But thank you.

With *elseif you need a final *else. Whilst you may be sure there are no other options, it is hardcoded into the code to ensure you have a final else to catch any occurence that doesn’t match any criteria.

As you are using goto for each option, you can put them all into individual *if, as once one fires, you dont care which other ones are true. That way you dont need any elseif or else.

Worth making sure that is intended behaviour. Someone with intelligence and endurance 10 will always hit the first condition and never the last.

Separately, you can simplify your first three checks into one, as they have the same outcome.

1 Like

So I tried it. I also found something on the web. It still didn’t work. So I finally gave up. I guess this is still too complicated for me. So instead, I recalculated the stats and made it so that when the option was selected, it just gave the player the number they needed in that stat and took them to the scene where they should go anyway. I guess I was making it too complicated. At this point in the game, if the player chooses intelligence or strength anyway, it’s pretty clear which way they want to lead their character.
It’s working now. I’ll try to deal with this problem some other time because I’m sure I’ll need this later. :slight_smile:

Thanks for the advice.

Did you get an error, or did it simply not work as intended? I didn’t find from your original post what the actual problem was.

1 Like

Well, the same phrase as the one in the title of the discussion kept popping up. :slight_smile:
Eventually, then I found on the internet this code:

*create implicit_control_flow true

With that, I got rid of the message, and the error didn’t appear, but the game still didn’t work, and it always ended up looking like it was the end of the game. I probably shouldn’t have attempted such a complicated thing when I’m still new to coding. :slight_smile:
Well, in the end I solved it in a different way.

Implicit control flow doesn’t fix errors in your game. It just turns off certain kinds of bug reports – and this is a textbook case of why not to do that.

Can I check something? Is there a *label firstencountercailus in your linam_know1.txt scene as well as your cailus_know1.txt scene? Because otherwise this goto_scene:

 *elseif (endurance > 9)
      *goto_scene linam_know1 firstencountercailus

might have been trying to send you to a label that only exists in the cailus_know1 scene…which could have been what’s crashing it.

Also, like people said, if you use if/elseif, you should end with an else, not just a string of elseifs.

Edit: was your intention for high intelligence, charisma, and speed to all take you to one scene, and high strength and endurance to take you to another? If so, you could do that like this:

*if (strength > 9) or (endurance > 9)
  *goto_scene cailus_know1 firstencountercailus
*elseif ((intelligence > 9) or (charisma > 9)) or (speed > 9)
  *goto_scene linam_know1 firstencounterlinam
*else
  *goto boring_normal_next_part

I don’t use goto_scene at all in my own writing, so can’t guarantee that that part of it will work – but if you still get a crash from that, it’s a problem with scene/label names, not with your if/else structure.

2 Likes

Thank you very much. I’ll try it as soon as I can.
Otherwise, yes, that’s exactly what I wanted. :slight_smile: so that the player doesn’t really “have” a choice in where the scene moves to, but it will depend on how they “build” their character.
I’ll try it out later.
Thank you :slight_smile: