Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Reaper Games© on Sun 02/05/2004 11:44:43

Title: (Global script) help
Post by: Reaper Games© on Sun 02/05/2004 11:44:43
i want to add this:


if (keycode == 361) SaveGameDialog(); but  when i save game, it says :

Error (line 108): parse error:unexpected 'if'

:( help
Title: Re:(Global script) help
Post by: Dusk on Sun 02/05/2004 12:02:32
Quote from: Reaper Games© on Sun 02/05/2004 11:44:43
if (keycode == 361) SaveGameDialog(); but  when i save game, it says :

Error (line 108): parse error:unexpected 'if'


I think that there must be an error *before* the if...  :)
bye
Title: Re: (Global script) help
Post by: Pumaman on Sun 02/05/2004 13:59:01
You'll have to post more of your script - post the surrounding lines so we can see where the problem is.
Title: Re: (Global script) help
Post by: Reaper Games© on Sun 02/05/2004 15:00:22
   }
    if (button == 3) {
      // They pressed the OK button, close the GUI
      GUIOff (INVENTORY);
      SetDefaultCursor();
    }

    if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
      // scroll down
      game.top_inv_item = game.top_inv_item + game.items_per_line;
    }
    if ((button == 5) && (game.top_inv_item > 0)){
      // scroll up
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    }
  }
}   
      if (keycode == 361) SaveGameDialog();                         
Title: Re: (Global script) help
Post by: Hollister Man on Sun 02/05/2004 15:33:52
For me, that usually happens when I have accidentally placed more "close" braces than "open" ones, making the compiler think that you have ended the function before you actually meant to.  When it finds an "if" outside the function, it returns an error.  Unfortunately, you did not post enough of the code to check that.  Try the "match brace" tool with the first brace in the function, and see what you get.
Title: Re: (Global script) help
Post by: Kweepa on Sun 02/05/2004 17:30:08
I think there's enough code there to hazard a guess:
You need to put the added line inside the on_key_press function, not (as it appears to be) at the bottom of the global script.
Look for a line that says
function on_key_press(int keycode) {

And put it with the other similar lines after that.