Very strange occurance using the ChangeRoom function (SOLVED)

Started by Akumayo, Sun 26/02/2006 17:32:16

Previous topic - Next topic

Akumayo

I have the following code in one of my room's repeatedly_excecutes:

Code: ags

if (IsKeyPressed('B')) {
Ã,  if (se_continuous == 1) cBall.ChangeRoom(8);
}
if (IsKeyPressed('C')) {
Ã,  if (se_classic == 1) cBall.ChangeRoom(6);
}
if (IsKeyPressed('D')) {
Ã,  if (one_vert == 1) cBall.ChangeRoom(2);
}
if (IsKeyPressed('E')) {
Ã,  if (two_team_vert == 1) cBall.ChangeRoom(3);
}
if (IsKeyPressed('F')) {
Ã,  if (two_vers_vert == 1) cBall.ChangeRoom(4);
}
if (IsKeyPressed('G')) {
Ã,  if (two_team_full == 1) cBall.ChangeRoom(7);
}
if (IsKeyPressed('H')) cBall.ChangeRoom(10);
}


The problem is, when keys B-G are pressed, the screen fades out, like it's going to take me to the new room, but then stalls or something.Ã,  The screen stays black.Ã,  F9 and other keypresses are disabled.Ã,  Only Alt-X is pressable.Ã,  However, when key H is pressed, the game successfully moves to room 10.Ã,  I can't figure out what might be causing the error.Ã,  I've never run into anything like this before.Ã,  Any ideas?
"Power is not a means - it is an end."

Wretched

Not sure why your problem happens, try changing the 'B' press to room 10 and see if that works.
Also you should put a return; statement after each changeroom() call, as your code would crash if two keys were both held down simultaneously.

Akumayo

Thanks for pointing out the return thing, I added them.

I switched 'H' with 'B' and pressed B (now room 10), the game successfully loaded room ten.  I pressed H, and it once again took me to a black screen, and canceled my keypresses.
"Power is not a means - it is an end."

monkey0506

Instead of adding a return statement to each one, it would be easier (to code and to follow) if you put:

if (IsKeyPressed('B')) {
  // blah
  }
else if (IsKeyPressed('C')) {
  // blah
  }
// blah

Not sure what might be causing the error...but by any chance does it make a difference if you type it like:

Code: ags
if ((IsKeyPressed('B')) && (se_continuous == 1)) cBall.ChangeRoom(8);
else if ((IsKeyPressed('C')) && (se_classic == 1)) cBall.ChangeRoom(6);
// etc.


Not that it should...just asking.  And...you have a closing brace after 'H'...Could you post the entire function?

Akumayo

Noted.  Here's the whole function:

Code: ags

function room_b() {
  // script for Room: Repeatedly execute
if (IsKeyPressed('A')) {
  if (se_continuous == 1) {
    Display("Controls for Smash 'Em Continuous:");
    Display("Move left with 'A' and right with 'F'");
    Display("Arrow keys also work.");
    Wait(10);
  }
  if (se_classic == 1) {
    Display("Controls for Smash 'Em Classic:");
    Display("Move left with 'A' and right with 'F'");
    Display("Arrow keys also work.");
    Wait(10);
  }
  if (one_vert == 1) {
    Display("Controls for One Player Vertical:");
    Display("Move left with 'A' and right with 'F'");
    Display("Arrow keys also work.");
    Wait(10);
  }
  if (two_team_vert == 1) {
    Display("Controls for Two Player Team Vertical:");
    Display("Player 1 moves left with 'A' and right with 'F'");
    Display("Player 2 moves left with 'H' and right with 'L'");
    Wait(10);
  }
  if (two_vers_vert == 1) {
    Display("Controls for Two Player Versus Vertical:");
    Display("Player 1 moves left with 'A' and right with 'F'");
    Display("Player 2 moves left with 'H' and right with 'L'");
    Wait(10);
  }
  if (two_team_full == 1) {
    Display("Controls for Two Player Double-Paddle Fullscreen:");
    Display("Player 1 moves with 'A' and 'F'");
    Display("Player 2 moves with 'K' and 'M'");
    Wait(10);
  }
}
else if (IsKeyPressed('B')) {
  if (se_continuous == 1) cBall.ChangeRoom(8);
}
else if (IsKeyPressed('C')) {
  if (se_classic == 1) cBall.ChangeRoom(6);
}
else if (IsKeyPressed('D')) {
  if (one_vert == 1) cBall.ChangeRoom(2);
}
else if (IsKeyPressed('E')) {
  if (two_team_vert == 1) cBall.ChangeRoom(3);
}
else if (IsKeyPressed('F')) {
  if (two_vers_vert == 1) cBall.ChangeRoom(4);
}
else if (IsKeyPressed('G')) {
  if (two_team_full == 1) cBall.ChangeRoom(7);
}
else if (IsKeyPressed('H')) cBall.ChangeRoom(10);
}


The error persists still only on B-G, which is strange since all the functions call for a room change.  Any ideas?
"Power is not a means - it is an end."

monkey0506

The only thing I can figure is that perhaps the rooms are corrupted...?

Akumayo

#6
Oh my...
I tried setting the player character's starting position to room 4... a black screen, nothing happened.
Room 3, same thing, black screen.
:'(
How did my rooms get corrupted, if that is the problem?Ã,  What happened to kill them?Ã,  How do I fix it?

On the offchance that they are not corrupted, what is making them black and nonresponsive?

NOTE:Ã,  I used the debug feature that shows you what the game is doing/what scripts are bing run, etc.Ã,  It shows me everything that's being done until I enter one of the rooms, at which point it disapears.

EDIT:
HOLY CRAP!!!  Now the room where you access the nonresponsive rooms is non-responsive.  When I go to it, the screen/background load, enter-room interactions get run, and then keypresses, mouse-movement gets disabled!  (the backgrounds in the other rooms were a solid black)
"Power is not a means - it is an end."

monkey0506

Suggestion.  Salvage everything you can...and run.

Uh...honestly, I don't know what might have happened...but you might want to start a new game file (don't delete the old one in case Chris or someone wants you to upload it).

Ashen

Two things, both of which might be pointless, if you can't get near it at all now:

1) (Mostly out of pure curiosity) Why are you using IsKeyPressed(..) instead of on_key_press? What if you move them to on_key_press? It's possible (but I don't know how likely, since it doesn't for 'H') that calling a room change in rep_ex is causing your problem.


2) Could there be something in the non-responsive rooms themselves, that's causing it (a check in 'Player enters screen (before fadein), for example)?
I know what you're thinking ... Don't think that.

Akumayo

SOLVED!!!  ;D

Upon Ashen's request, I set about looking for a problem in the player enters screen sections.  I found it.  Buried within the script was a line that, rather than directly accessing character variables x and y, used ChangeRoom to restate the current room, and set the x and y.  Therefore, a ChangeRoom was being called in before the room loaded, causing a break-down in the engine.  There really should be an error message for that, it would've made things easier.
Thanks for all your help guys  :D
"Power is not a means - it is an end."

SMF spam blocked by CleanTalk