Skipping run-script

Started by sloppy, Mon 26/12/2005 14:44:27

Previous topic - Next topic

sloppy

I have the strangest thing happening and I was wondering if this has happened to anyone else. 
In having a conversation with an NPC, I'm running run-scripts in the dialog for certain things to happen.  If the player character says something, I'll have the following script that has him walk to the NPC, and then change rooms:
if (parameter==6)
character[GUY].Walk(70, 115, eBlock);
player.ChangeRoom(22);

If the character says goodbye, the dialog stops, and the NPC wil go into a constant nonblocking animation:
if (parameter==7)
character[JIL].LockView(20);
character[JIL].Animate(0, 4, eRepeat,eNoBlock, eForwards);
}

Here's what's happening and I can't figure out why.  When the dialog that says "goodbye" occurs, where paramter 7 should happen, it changes to room 22.  I have tried every variation to see why this happens, I've tried switching the parameter numbers, and the run-scripts in the dialogs, but the same thing happens.  Is there something that I'm not seeing?

DoorKnobHandle

I don't know if the code that you posted here is exactly what you use in AGS as well, but your braces are majorly messed up.

Code: ags

if ( parameter == 6 )
{
   // do stuff
}

if ( parameter == 7 )
{
   // do stuff
}


Please use the [_code] and [_/code] tags without underscores next time you post any of your script material.

strazer

Yes, you have to enclose multiple commands within brackets, otherwise the conditional only works on the first command. Your code is the same as

Code: ags

  if (parameter==6) cGuy.Walk(70, 115, eBlock);
  player.ChangeRoom(22); // this happens every time


Try this instead:

Code: ags

  if (parameter==6) { // note the opening bracket
    cGuy.Walk(70, 115, eBlock);
    player.ChangeRoom(22);
  } // closing bracket


Don't forget to do the same with your other parameters as well:

Code: ags

  if (parameter==7) {
    cJil.LockView(20);
    cJil.Animate(0, 4, eRepeat,eNoBlock, eForwards);
  }

sloppy

Thanks, you were right about the brackets, I didn't realize all the commands had to be enclosed.  It always worked before, but I guess that's because it was only a single command every other time.

It works now. 

SMF spam blocked by CleanTalk