I did nested if/else statements before in my RON learning project, but this time I must be overlooking something.
I have this:
function room_AfterFadeIn()
{
if (cChpaltr.Room == 34){ //Elaine is in church
if (Game.DoOnceOnly("MeetElaine") == true){
cChpaltr.Say("Something");
//do things
}
else{ //already talked to Elaine
cChpaltr.Say("Something else");
//do more things
}
else{ //Elaine not in church
cLan.Walk(285, cLan.y, eBlock, eAnywhere);
}
}
I get a parse error at the else-line that says //Elaine not in church.
What am I doing wrong?
thanks
Unless I've miscounted (or you've mis-copied), you're missing a closing brace at the end of the function.
You have an opening bracket in
"if (cChpaltr.Room == 34){"
that you haven't closed, so a } right before the line where you get the parse error should help.
In general, with your indentation style, check for every if/else that there is a closing bracket at the same indentation level to find such mistakes.
Edit: Victor, no, the function has a closing bracket, it's the inner bracket that's missing.
Ok, thanks.
I keep forgetting that you have to close the if-statement also if there's an else coming.
I used to toy with visual basic where you only close after the last else.
HandsFree don't forget you can press Ctrl+B when your cursor is next to a bracket.
This highlights the matching brace in yellow.
If the bracket has no counterpart it's highlighted in red.
Cool, I didn't know that.