Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: sloppy on Sun 13/11/2005 22:25:21

Title: Change room after dialog.
Post by: sloppy on Sun 13/11/2005 22:25:21
I've run into a strange problem.  What I want to happen is the character changes rooms right after a certain dialog takes place.
I've done the dialog request function in the global script.  When the NPC says something in the dialog editor, I have run-script 3 which triggers the variable.  In the interact with hot-spot, that's where the whole thing starts. And where I have the variable that if the dialog takes place the player character changes room.  But I'll go through the interaction, and then the proper dialog sequence, and then...nothing happens.

Obviously I'm not doing this quite right.  And the way I understand it, it should work.
I'd appreciate any help I can get on this.
Title: Re: Change room after dialog.
Post by: Candle on Sun 13/11/2005 22:48:40
Best to show code if your using code to do it?
Title: Re: Change room after dialog.
Post by: sloppy on Mon 14/11/2005 04:49:21
Here's what I have:

Global script:
int to_jail;
export to_jail;

function dialog_request(int parameter) {
  if (parameter==1)
    to_jail=1;
}

Script header:
import int to_jail;

(I interact with a door in Room 15.  NPG walks on screen and we have a conversation.  At a point in the conversation, I want my player character to go to Room 16.)

Dialog editor:
ORT: Is that a fact?
run-script 1
stop

Interaction editor in Room 15:
if (to_jail==1) { 
character[EGO].ChangeRoom(16, 218, 200);
}

That's about it.  Am I doing something wrong?
Title: Re: Change room after dialog.
Post by: Gilbert on Mon 14/11/2005 05:01:14
You only wrote "Interaction editor in Room 15:", which interaction did you actually put those codes in?
Title: Re: Change room after dialog.
Post by: sloppy on Mon 14/11/2005 05:12:10

It's in the "Interact hotspot" script.
Title: Re: Change room after dialog.
Post by: Gilbert on Mon 14/11/2005 05:19:03
Change it to "repeatedly_execute".
Otherwise you need to interact with the hotspot a second time for the room change.
Title: Re: Change room after dialog.
Post by: sloppy on Mon 14/11/2005 05:37:59
Okay, I tried putting
"if (to_jail==1) {
character[EGO].ChangeRoom(16, 218, 200);
}"

in repeatedly_execute of the Room Editor.  Still nothing happens when I finish that dialog.
Title: Re: Change room after dialog.
Post by: Gilbert on Mon 14/11/2005 06:23:37
Place a display line in dialog_request and check if the function was indeed get called, and if the variable was set correctly:

function dialog_request(int parameter) {
Ã,  if (parameter==1)Ã,  to_jail=1;
Ã,  Display("to_jail=%d",to_jail);
}
Title: Re: Change room after dialog.
Post by: Wretched on Mon 14/11/2005 08:10:18
Why not just put

character[EGO].ChangeRoom(16, 218, 200);

in the dialog_request script ?
Title: Re: Change room after dialog.
Post by: sloppy on Mon 14/11/2005 14:24:29
Gilbot, I did what you said and once the dialog was finished, I would get a display that read: "to_jail=1".  And then nothing else.

Wretched, I tried your suggestion and it worked perfectly.  I still don't know why it wouldn't work the other way, but I'm content with the results.
Thanks for the help everyone.
Title: Re: Change room after dialog.
Post by: strazer on Mon 14/11/2005 19:07:25
Quote from: sloppy on Mon 14/11/2005 14:24:29I still don't know why it wouldn't work the other way

Did you create the room's rep_ex function using the interaction editor? Putting a "repeatedly_execute" function directly into the room script doesn't work at the moment (http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=514).
Title: Re: Change room after dialog.
Post by: Revan on Wed 23/11/2005 12:35:05
Quote from: Wretched on Mon 14/11/2005 08:10:18
Why not just put

character[EGO].ChangeRoom(16, 218, 200);

in the dialog_request script ?
what is the dialog_request script ? Im having the same problem
Title: Re: Change room after dialog.
Post by: strazer on Wed 23/11/2005 12:36:42
http://www.adventuregamestudio.co.uk/yabb/index.php?action=search