Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Colxfile on Wed 08/02/2006 09:55:45

Title: What type is GetGameParameter? (SOLVED)
Post by: Colxfile on Wed 08/02/2006 09:55:45
I'm intending to get the height and width of a sprite and store these in a couple of variables like so:

int sprite_width = GetGameParameter(GP_SPRITEWIDTH, mush_sprite, 0, 0);
int sprite_height = GetGameParameter(GP_SPRITEHEIGHT, 4, 0, 0);


However, the compiler doesn't like this and says "Expected integer expression after '=' ".

What am I doing wrong?
Title: Re: What type is GetGameParameter?
Post by: Gilbert on Wed 08/02/2006 10:58:53
I expect you put that outside of functions (like on top of the script say for example).

You can only call functions, do computations, etc., within functions. When outside of functions you can only assign constant values:

int a = 16; //this is okay EVERYWHERE

int b = a;                //  \    These cannot be used
int c = 5 + 6;            //   |-- outside functions, but are
int d = GetViewportX();   //  /    okay within functions.


Much prefered format is to declare the variables outside or inside a function:

int sprite_width;
int sprite_height;

And then assign their values inside some function (according to your need, like for example if you want it to be done whenever a character enters a room, put them in one of the "player enters room(...)" interaction):
sprite_width = GetGameParameter ( GP_SPRITEWIDTH, mush_sprite, 0, 0 );
sprite_height = GetGameParameter ( GP_SPRITEHEIGHT, 4, 0, 0 );

Title: Re: What type is GetGameParameter? (SOLVED)
Post by: Colxfile on Wed 08/02/2006 12:50:28
Yes. I should have said that these variables were being declared outside of functions in my script. Thank you. :)