What type is GetGameParameter? (SOLVED)

Started by Colxfile, Wed 08/02/2006 09:55:45

Previous topic - Next topic

Colxfile

I'm intending to get the height and width of a sprite and store these in a couple of variables like so:

Code: ags
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?
Always carry a UV marker pen with you. When you go to a shop or a friend's house, if you see something you like, put your name and postcode on it. If it gets stolen and subsequently recovered, the police will get in touch with you so that they can 'return' it.

Gilbert

#1
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 );


Colxfile

Yes. I should have said that these variables were being declared outside of functions in my script. Thank you. :)
Always carry a UV marker pen with you. When you go to a shop or a friend's house, if you see something you like, put your name and postcode on it. If it gets stolen and subsequently recovered, the police will get in touch with you so that they can 'return' it.

SMF spam blocked by CleanTalk