Nested if else error


*if stuff
 *set stuff
*else
 *set stuff

basically…

*if stuff
 *set stuff
 *goto somewhere
*else
 *set stuff
 *goto somewhere
2 Likes

Can I make it so that it doesn’t have a goto statement and continues to the next block?

Yes, a *fake_choice might work, otherwise you might want to look into implicit control flow.

At the end of the selectable_if there is a *goto player_turn, is it possible to execute that after the if block unconditionally like

*choice
  #Choice 1
    *if (a)
      *set var1 true
    *else
      *set care true
    *goto label

Or is it necessary to indicate goto in each branch of the if

*choice
  #Choice 1
    *if (a)
      *set var1 true
      *goto label
    *else 
      *set var1 false
      *goto label

In a *fake_choice, your top example should work.
I believe a regular *choice needs *goto after every *if, *elseif, or *else command.

I tried to use fake choice and no luck, same error. I think I’ll make my nested ifs into if lists and see if that works. Thanks for the help

1 Like

This seemed to have fixed the problem by adding a goto statement at the end of the inner else block. I think the problem is with nesting the if statements without explicit control flow, so I’m guessing using listed ifs would work as well. Very ugly but I guess I sort of works. If anyone has alternate solutions, please comment. My spaghetti choicescript is messing up my mind right now.

*selectable_if (stealth>=50) #Efficient silent strides
        *set fight_msg "You silently but swiftly approach the opponent"
        *if (((1 + (stealth / 100)) *opp_dist) < (opp_awareness))
          *set opp_alerted true
        *if (facing_opp)
          *if (opp_dist>(agility/1.5))
            *set opp_dist - (agility/1.5)
          *else
            *set opp_dist 0
            *goto player_turn
        *else
          *set opp_dist + (agility/1.5)
        *goto player_turn
*selectable_if (stealth>=50) #Efficient silent strides
        *set fight_msg "You silently but swiftly approach the opponent"
        *if (((1 + (stealth / 100)) *opp_dist) < (opp_awareness))
          *set opp_alerted true
          *goto facingoppcalc
        *label facingoppcalc
        *if (facing_opp)
          *if (opp_dist>(agility/1.5))
            *set opp_dist - (agility/1.5)
            *goto player_turn
          *else
            *set opp_dist 0
            *goto player_turn
        *else
          *set opp_dist + (agility/1.5)
          *goto player_turn
        *goto player_turn
2 Likes

You’re always gonna need a *goto at the end of every *if and every *else or you’ll get the error. To disable this requirement use implicit control flow as suggested above.

More info on how to use it here:

2 Likes