Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Blondbraid on Sun 24/04/2016 12:25:50

Title: Pausing a script until a dialog stops
Post by: Blondbraid on Sun 24/04/2016 12:25:50
Hello, I'm wondering whether it's possible to pause the script and make it not start running again until until a dialog running has stopped.
What I try to make happen is:

1. The script runs as usual.
2. The dialog starts.
3. The player pick a dialog option and the dialog stops.
4. The script commands taking place after the dialog doesn't start until the dialog has stopped.

As the script looks now, whatever commands I write below the dialog.start(); command begins before the dialog.
I wonder if there is a simple solution to this besides having to write later commands into the actual dialogue?
Title: Re: Pausing a script until a dialog stops
Post by: Slasher on Sun 24/04/2016 13:42:32
Dialogs get put to the end of the function. You will need to script around it.
Title: Re: Pausing a script until a dialog stops
Post by: Blondbraid on Sun 24/04/2016 14:20:26
Quote from: slasher on Sun 24/04/2016 13:42:32
Dialogs get put to the end of the function. You will need to script around it.
Yes, but I'm unsure of how to do it, and I wonder if there is any alternative ways to script around it or if the only way is to put the script commands inside the dialogue.
Title: Re: Pausing a script until a dialog stops
Post by: Khris on Sun 24/04/2016 23:39:33
Dialogs will pause the room's repeatedly_execute, so you could create a global boolean called after_dStuff1, initial value false, then do this:
// in dialog script
  after_dStuff1 = true;
stop

// in room's rep_exec
  if (after_dStuff1) {
    after_dStuff1 = false; // only once
    // stuff that happens after dialog here
  }
Title: Re: Pausing a script until a dialog stops
Post by: Blondbraid on Tue 26/04/2016 09:51:27
Thank you Khris!
I've tried to implement what you wrote, but I get this error message whenever I try to start the game:
room25.asc(42): Error (line 42): undefined symbol 'after_dStuff1'
I don't understand what I missed. :(
Title: Re: Pausing a script until a dialog stops
Post by: Khris on Tue 26/04/2016 09:56:52
Did you create a global boolean variable of the same name, like I said? You need to use the Global Variables pane for that.
Title: Re: Pausing a script until a dialog stops
Post by: Blondbraid on Tue 26/04/2016 10:04:34
Quote from: Khris on Tue 26/04/2016 09:56:52
Did you create a global boolean variable of the same name, like I said? You need to use the Global Variables pane for that.
I tried, but I'm not sure on how to do it, so I just wrote after_dStuff1 = false; into the global script.
Title: Re: Pausing a script until a dialog stops
Post by: Cassiebsg on Tue 26/04/2016 10:46:14
On your tree project open the Global Variables pane (it has a blue sphere icon), right click on an empty space (should be plenty, since you obviously have not created any yet), choose Add new variable. Type the name of the new variable (after_dStuff1), choose bool, write false on the value, click ok... and there, done! (nod)

Remember to delete that entry from global scripts.
Title: Re: Pausing a script until a dialog stops
Post by: Blondbraid on Tue 26/04/2016 11:04:34
I tried it and it seems to be working as it should. Thank you so much! ;-D