Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Chim on Fri 01/10/2010 17:12:34

Title: Dialog scripting - end of dialogue detection * Solved *
Post by: Chim on Fri 01/10/2010 17:12:34
Hello AGS community,

I am starting with AGS and I am currently trying out the possbilities and function of this very useful tool.

However, I have a question for which I could not find my own answer by looking in the tutorial and unfortunately, a big part of the online manual seems to be down and to redirect to a 404 error.

To the point now :

Is it possible to detect the end of a dialog after using a dDialog.Start(); in a room script ?
Currently, at the first load of my room, a character walks toward my hero and start a dialog with him. At the end of this dialog, I would like to change the room in which my hero is.

This is probably very simple, but as I am still not very familiar with the place I am supposed to put code into , I prefer to ask.

Thank you in advance :)
Title: Re: Dialog scripting - end of dialogue detection
Post by: cianty on Fri 01/10/2010 20:48:01
The only solution I can think of is to use the CallRoomScript function. Simply add this to your dialog (right before the stop):

...
  CallRoomScript(1);
stop

----------------------------

Then add the on_call function to the room where the dialog is taking place and where you want the action to take place:

function on_call(int var){
  if(var==1){
    <code to happen after dialog end>
}
}

Of course, you don't have to use the parameter 1 - use whatever number you consider suitable. Just be aware that if the dialog is started in another room, then at the end the on_call function will be always called so if you have this function implemented in that other room it may have some unexpected effects. So, if we're talking room 10 e.g., you might want to do this in the dialog:

...
  if(player.Room == 10)CallRoomScript(1);
stop


This could prevent undesired calls of the RoomScript function.
Title: Re: Dialog scripting - end of dialogue detection
Post by: Chim on Fri 01/10/2010 22:11:06
Thank you very much for this tip. I did not know it was possible to invoke a room script in a dialog. This will reveal quite useful.

I am going to try this right away.
Title: Re: Dialog scripting - end of dialogue detection
Post by: Chim on Sat 02/10/2010 10:12:43
Unfortunately, as for my other tries, the script dialog does not know the CallRoomScript command.

Is there a special parameters I should activate in order to use that kind of functions in a dialog script ?
Title: Re: Dialog scripting - end of dialogue detection
Post by: GarageGothic on Sat 02/10/2010 10:17:41
You should indent the line if you want to run normal script commands from within a dialog script. Just put a couple of spaces or a tab at the start of the line and you should be fine.
Title: Re: Dialog scripting - end of dialogue detection
Post by: Chim on Sat 02/10/2010 10:29:08
Ok, thanks. I was sure I was missing a very simple point :)