Pausing a script until a dialog stops

Started by Blondbraid, Sun 24/04/2016 12:25:50

Previous topic - Next topic

Blondbraid

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?


Slasher

Dialogs get put to the end of the function. You will need to script around it.

Blondbraid

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.


Khris

Dialogs will pause the room's repeatedly_execute, so you could create a global boolean called after_dStuff1, initial value false, then do this:
Code: ags
// 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
  }

Blondbraid

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. :(


Khris

Did you create a global boolean variable of the same name, like I said? You need to use the Global Variables pane for that.

Blondbraid

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.


Cassiebsg

#7
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.
There are those who believe that life here began out there...

Blondbraid

I tried it and it seems to be working as it should. Thank you so much! ;-D


SMF spam blocked by CleanTalk