Parse error: unexpected 'else'; help needed!--SOLVED

Started by JudasFm, Sun 18/07/2004 12:43:14

Previous topic - Next topic

JudasFm

I'm working on developing the interaction circle for my next game, but whenever I try and save it, I get a message saying 'Parse error: unexpected 'else' line 148', referring to the global script.Ã,  I've checked and double-checked the numbers, the GUIs, everything and I can't work out why it's messing up.Ã,  Anyone out there able to help?Ã,  I've pasted the entire code with the line in question in red, just to make it easier.

if (interface == INTERACTION) {
Ã,  Ã,  if (button == 0) {Ã,  // LOOK
Ã,  Ã,  Ã,  GUIOff(3);
Ã,  Ã,  Ã,  Ã, SetCursorMode(1);
Ã,  Ã,  Ã,  }
Ã,  Ã,  else if (button == 1) {Ã,  Ã, // interact
Ã,  Ã,  Ã,  GUIOff(3);
Ã,  Ã,  Ã,  Ã, SetCursorMode(2);
Ã,  Ã,  Ã,  }
Ã,  Ã,  else if (button == 2) {Ã,  Ã, // smell
Ã,  Ã,  Ã,  GUIOff(3);
Ã,  Ã,  Ã,  Ã, SetCursorMode(8);
Ã,  Ã,  Ã,  }
else if (button == 3) {Ã,  Ã, // sense
Ã,  Ã,  Ã,  GUIOff(3);
Ã,  Ã,  Ã,  Ã, SetCursorMode(10);
Ã,  Ã,  Ã,  }
else if (button == 4) {Ã,  Ã, // listen
Ã,  Ã,  Ã,  GUIOff(3);
Ã,  Ã,  Ã,  Ã, SetCursorMode(9);
Ã,  Ã,  Ã,  }
else if (button == 5) {Ã,  Ã, // inventory
Ã,  Ã,  Ã,  GUIOn(2);
Ã,  Ã,  Ã,  GUIOff(3);
Ã,  Ã,  }
else if (button == 6) {Ã,  Ã, // talk to
Ã,  Ã,  Ã,  Ã, SetCursorMode(3);Ã,  Ã,  Ã, 
GUIOff(3);
Ã,  Ã,  Ã,  }
else if (button == 7) {Ã,  Ã, // walk
Ã,  Ã,  Ã,  GUIOff(3);
Ã,  Ã,  Ã,  Ã, SetCursorMode(0);
Ã,  Ã,  Ã,  }
else if (button == 4) {Ã,  Ã, // listen
Ã,  Ã,  Ã,  GUIOff(3);
Ã,  Ã,  Ã,  Ã, SetCursorMode(9);
Ã,  Ã,  }
else if (button == 8)Ã,  Ã,  // save game
Ã,  Ã,  Ã,  Ã, GUIOff(3);
Ã,  Ã,  Ã,  SaveGameDialog();
Ã,  Ã,  Ã,  }
Ã,  Ã,  else if (button == 11)Ã,  Ã, // load game
Ã,  Ã,  Ã,  GUIOff(3);
Ã,  Ã,  Ã, RestoreGameDialog();

Ã,  Ã,  Ã,  }
Ã,  Ã, else if (button == 10) // quit game
Ã,  Ã,  GUIOff(3);
Ã,  Ã,  Ã, GUIOn(6);
Ã,  Ã,  Ã, CentreGUI(6);
Ã,  Ã,  Ã, }
Ã,  Ã, else if (button == 9) // restart game
Ã,  Ã,  GUIOff(3);
Ã,  Ã,  GUIOn(5);
Ã,  Ã,  CentreGUI(5);
Ã,  Ã,  }
Ã,  }
if (interface == SAVEPROMPT) {
Ã,  if (button == 1) // save game
Ã,  Ã, GUIOff(4);
Ã,  Ã, SaveGameDialog();
Ã,  Ã, RestartGame();
Ã,  Ã, }
else if (button == 2) // don't save
Ã,  Ã, GUIOff(4);
Ã,  Ã, RestartGame();
Ã,  Ã, }
else if (button == 3) // cancel
Ã,  Ã, GUIOff(4);
Ã,  Ã, }
}

Thanks!

Sinitrena

You've forgot one of this { (don't know what it's called),
else if (button == 8 ) {   // save game
       GUIOff(3);
      SaveGameDialog();
      }
    else if (button == 11)   // load game
      GUIOff(3);
     RestoreGameDialog();
      }
It's the red pasted. You've forget it at the button before youre problem line. You closed a } witch you didn't open before.

JudasFm

Oops  :-[ Can we say, duh? *cringes in embarrassment* Now it's screaming about an unexpected 'if', but I think I can get that done.  Thanks so much for your help! :D

Pumaman

well let's just say you're missing the opening brace on all your if statements from the one Sinitrena pointed out, onwards.

ryan

i get a similar error:

Parse error: unexpected 'Display'

the line:

Display (Morning in Reality...)

??? ??? ???  ::)

Gilbert

If it's exactly the line copied from your game's script, you missed a couple of things, namely the double quotes around the string and the semicolon ending a line.
(Though judging from your error message I think there're more to this, probably some scripting mistakes in lines before this one too.)

Display ("Morning in Reality...");

ryan

well, when i put the double colons and semicolon (turns out like this:  Display ("Morning in Reality..."); ), it just gets the error " Parse error: unexpected 'Display' ", and when i put single colon and semicolon ( Display ('Morning in Reality...'); ), i get " Incorrectly terminated character constant ".  ???

and this is the first line of code in the script, no one code is before it.  :-\

Sinitrena

Where exactly in the script is this line, what is the function it is put in?

ryan

well, here, this is the room's whole script (the line with the error being at the top):



and the error i get without the colons and such



here it is with the double colons and semicolon (the line with the error being at the top)::



and it gets the same error as above

but with single colons and a semicolon, its gets this error:



as u can see, the line is at the top. is there perhaps an extra something i have to put before the first line or something? thank you for your guy's help.  ;D

Sinitrena

You want this to happen the first time youre character is in the room, right at the beginning of the game, don't you? Well, first of all, you need the double colons and semicolon in every single line if the whole display thing.
And the other problem, the reason for the error message, is that ags doesn't understand you here. You need to specify when these thing should be displayed. You must click on the interaction buttion in the room editor (The button with the I on it), then you must choose "First time player enters screen", then in the next window, "run script", then you must click on edit script and write your script down, or (a little bit shorter, because you don't have to write all again) , click on "OK" after you have choosen "run script", click  on the script button (you will see a few added lines there, don't change them), cut out the script you've already written and paste it between { and } of the new added lines.
And don't forget double colons and semicolons.

ryan

finally got it! phew, thank you very much Sinitrena, saved my game  ;D ;D ;D

ryan

altough i did partly get what i wanted, i wanted the majority of the messages to be display as normal text (like in  box or something), and i didn't want it to make the character say it. how to i get it to display as normal text? thank you again.

Pumaman

You've probably selected "Always display text as speech" in the Game Settings pane, which will cause everything to be said by the character. Untick that to get what you're after.

ryan


SMF spam blocked by CleanTalk