Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: left on Sat 09/04/2005 20:49:24

Title: error message when using code in b4 fade in (SOLVED)
Post by: left on Sat 09/04/2005 20:49:24
i am using some code in my game which switches the view of the room the charater is in, i am doing this using regions and global variables in the before fade in section

it works fine but when i quit the game  messages appear telling me to put the code (which is based on move character and set global int) into the after fade in section becuase i am calling a wait function.

I think i understand why this code should go in the after fade in section but:
the problem is that when i do this the game crashes, i have also tried the when player enters screen section but to no avail.

is it a big deal leaving my code in the before fade in section

code example:
if (GetGlobalInt(1) == 1) { //if the player has come from room 5
 
character[EGO].x=(191);
character[EGO].y=(127);

MoveToWalkableArea(EGO);
MoveCharacterBlocking(EGO, 197, 161, 1);

}
else {
character[EGO].x=(153);
character[EGO].y=(190);
}
 
 
Title: Re: error message when using code in b4 fade in
Post by: FrogMarch on Sat 09/04/2005 20:55:26
I guess you want your character to be walking as the screen fades in. Why not just put the 'MoveCharacterBlocking(EGO, 197, 161, 1);' bit in the after fade in section?

Also, is it absolutely necessary that the move character code has to be blocking? This is what is causing the problem, I think, in the before fade in section, as it is a wait function. If it can be avoided, try using MoveCharacter(EGO, 197, 161);' instead.
Title: Re: error message when using code in b4 fade in
Post by: on Sun 10/04/2005 03:40:28
Try this:


// script for room: Player enters screen (before fadein)

if (character[GetPlayerCharacter()].prevroom == 5) { //if the player has come from room 5

  character[EGO].x = 191;
  character[EGO].y = 127;

  MoveToWalkableArea(EGO);

}
else {
  character[EGO].x = 153;
  character[EGO].y = 190;
}



// script for room: Player enters screen (after fadein)

if (character[GetPlayerCharacter()].prevroom == 5) {
  MoveCharacterBlocking(EGO, 197, 161, 1);
}


Edit: previousroom -> prevroom
Title: Re: error message when using code in b4 fade in
Post by: left on Sun 10/04/2005 16:42:33
this works thank you


however the code as it is does not work: previousroom must be spelt prevroom for it to work. In fact i just cut that code down to (character[EGO].prevroom == 5);

thanks
Title: Re: error message when using code in b4 fade in
Post by: strazer on Sun 10/04/2005 20:21:45
Yeah, sorry, I didn't have AGS or the manual handy. The property is called "PreviousRoom" in AGS v2.7.

And I used GetPlayerCharacter() because not in all games the player character is named EGO.

Anyway, glad I could help.