NewRoomEx scripting problem [SOLVED]

Started by NiksterG, Sun 20/03/2005 21:13:21

Previous topic - Next topic

NiksterG

Here is my script:

Ã,  else if (parameter == 3)
Ã,  Ã,  {MoveCharacter (GHOST, 190, 150);
Ã,  Ã,  WaitKey (80);
Ã,  Ã,  NewRoomNPC (GHOST, -1, 25, 160);
Ã,  Ã,  StartCutscene(1);
Ã,  Ã,  Display ("Here is some text.");
Ã,  Ã,  NewRoom(3);
Ã,  Ã,  Display ("Here is some more text.");
Ã,  Ã,  WaitKey (40);
Ã,  Ã,  FaceLocation (NIK, 150, 160);
Ã,  Ã,  TintScreen (100, 50, 0);
Ã,  Ã,  Display ("More text.");
Ã,  Ã,  Display ("Text.");
Ã,  Ã,  Display ("Guess.");
Ã,  Ã,  MoveCharacter (NIK, 5, 170);
Ã,  Ã,  MoveCharacter (NIK, 160, 160);
Ã,  Ã,  Display ("More text.");
Ã,  Ã,  DisableHotspot(2);
Ã,  Ã,  MoveCharacter (NIK, 92, 155);
Ã,  Ã,  SetCharacterView (NIK, 5);
Ã,  Ã,  AnimateCharacter (NIK, 0, 5, 0);
Ã,  Ã,  ReleaseCharacterView (NIK);
Ã,  Ã,  SetCharacterView(NIK, 9);
}
}


The last three commands are equivelent to the quick animation setting in the interaction editor.

My problem is that it doesn't go to the new room when it is supposed to. It only goes there when all command have been done. I really need help! Once I figure this out, I'll be able to fix my game to perfection!
Check out my games! (Not all made with AGS)

Ubel

After you use NewRoom command, it stops running any more commands. So you can't put any commands after the NewRoom code.

strazer

NewRoom/Ex are delayed-response commands, meaning they get executed after the script finishes.
So you have to put the stuff that should happen in the other room into the "Player enters screen (after fadein)" interaction of that room. You can set a global variable beforehand and make these commands execute only when this variable is set.

NiksterG

Ok, that all makes sense. I'll try strazer's technique, but first tell me this...

How do you make a variable? (Sorry if this sounds noobish, I'm super bad at scripting and such)
Check out my games! (Not all made with AGS)

strazer

#4
Although you can define custom script variables, it's easier to use the predefined GlobalInts for this kind of thing.

There are 500 built-in global variables available, from index 0 to 499.
You can set their values with SetGlobalInt and retrieve them with GetGlobalInt, like this:

Code: ags

  // some interaction

  SetGlobalInt(28, 1); // set global variable 28's value to 1 (default value is 0)
  NewRoom(3); // go to room 3


Code: ags

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

  if (GetGlobalInt(28) == 1) { // if global variable 28 is 1
    // do stuff
    SetGlobalInt(28, 0); // reset variable 28's value
  }

NiksterG

Okay, so if I write:

SetGlobalInt(1, 1);
StartCutscene(1);
Ã,  Ã,  Display ("Text");
Ã,  Ã,  if (GetGlobalInt(1) == 1)
Ã,  Ã,  Ã,  Ã, {NewRoom(3);
Ã,  Ã,  Ã,  Ã, }
Ã,  Ã,  Display ("Text");
Ã,  Ã,  WaitKey (40);
Ã,  Ã,  FaceLocation (NIK, 150, 160);
Ã,  Ã,  TintScreen (100, 50, 0);
Ã,  Ã,  //etc., etc...

That will bring him to the new room when I want him to go? Because if it is, that's what I put in, and it's not working.
Check out my games! (Not all made with AGS)

strazer

Code: ags

  //...
  else if (parameter == 3) {
    MoveCharacter (GHOST, 190, 150);
    WaitKey (80);
    NewRoomNPC (GHOST, -1, 25, 160);
    StartCutscene(1);
    Display ("Here is some text.");

    SetGlobalInt(1, 1);

    NewRoom(3);
  }
  //...


Code: ags

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

  if (GetGlobalInt(1) == 1) { // if global variable 1 is 1

    Display ("Here is some more text.");
    Wait (40);
    FaceLocation (NIK, 150, 160);
    TintScreen (100, 50, 0);
    Display ("More text.");
    Display ("Text.");
    Display ("Guess.");
    MoveCharacter (NIK, 5, 170);
    MoveCharacter (NIK, 160, 160);
    Display ("More text.");
    DisableHotspot(2);
    MoveCharacter (NIK, 92, 155);
    SetCharacterView (NIK, 5);
    AnimateCharacter (NIK, 0, 5, 0);
    ReleaseCharacterView (NIK);
    SetCharacterView(NIK, 9);

    EndCutScene();

    SetGlobalInt(1, 0); // reset variable's value
  }

NiksterG

Thank you so much! I did what you told me, and there were a few bugs, but I worked them out. My game run smoothly again!Ã,  ;D
Check out my games! (Not all made with AGS)

SMF spam blocked by CleanTalk