Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Babar on Mon 01/09/2003 13:16:27

Title: using scripts in dialogs
Post by: Babar on Mon 01/09/2003 13:16:27
I used run-script 2 in one of my dialogs. In the script I called another dialog with Run-dialog 11. I got an error when I tested the game saying that I was already in one dialog and could not call another, so I put StopDialog in the script before using Rundialog, but I still get the message that I am already in one dialog and cannot call another. I know I am reaally bad at scripting so it is probably something stupid I did, but I need help to get it right
Title: Re:using scripts in dialogs
Post by: Ishmael on Mon 01/09/2003 14:32:26
I have had that problem also. What you could try (not tested, though):

in dialog point where you want to swich to another dialog:

run-script 2
run-script 3

or if 2 and 3 are in use, pick ones that are not.

and in dialog_request:
for run-script 1:
StopDialog();
and for run-script 2:
RunDialog(11);

might work, but I'm not sure, not at all.
Title: Re:using scripts in dialogs
Post by: Babar on Mon 01/09/2003 16:17:50
No.....It doesn't work. I didn't think it would anyways, because if the dialog is stopped in script 1 then then it would not go back to the dialog to check script 2 at all. I would be really grateful if I could get help to solve this problem, because I really can't think of anyway around it in the game I am making
Title: Re:using scripts in dialogs
Post by: SSH on Mon 01/09/2003 16:36:19
Quote from: Babloyi on Mon 01/09/2003 13:16:27
I used run-script 2 in one of my dialogs. In the script I called another dialog with Run-dialog 11.

Is that the last thing in the script? WHy not just let it return to the dialog script and do an:

goto-dialog 11

straight after your run-script 2


Title: Re:using scripts in dialogs
Post by: Babar on Mon 01/09/2003 16:52:08
I can't do that.... the script I call from the dialog checks some variable and if it is 0 it goes to dialog 10 and if it is 1 it goes to 9
Title: Re:using scripts in dialogs
Post by: Scummbuddy on Mon 01/09/2003 16:58:44
Then set up a new dialog to be sent to that picks up where you left off and with the dialog choices you want.
Title: Re:using scripts in dialogs
Post by: SSH on Mon 01/09/2003 16:58:54
AH, I see.

Well, one possibility is to let it drop out of the dialog completely, having set some global variable and then check that global variable after you call the original dialog.

Is that clear?

e.g.

RunDialog(1); // this is your dialog which calls the run-script 2
if (GetGlobalInt(77)==1) {
RunDialog(9);
} else if (GetGlobalInt(77)==2) {
RunDialog(10);
}

and then your dialog_request has:
SetGlobalInt(77, whatever_is_appropriate);
StopDialog();

Although this is pretty unwieldy!


Alterntaively, merge your two alternative dialogs into one and then use your run-script to turn off the wrong set of options and turn on the correct ones...?
Title: Re:using scripts in dialogs
Post by: Babar on Wed 03/09/2003 10:24:20
Its not working!!! :'(. I tried what you said SSH, and it solved the problem with the error messages, but now everything else is messed up. No matter which value is assigned to the GlobalInt, it always goes to the same dialog. There are two scripts that were used for the Talk to character interaction. I don't remember why I put them as two, but I thought it will make no difference so I didn't change it back to one:
1st Script:
RunDialog(0);

2nd Script:
If (GetGlobalInt(11)==1) RunDialog(9);
If (GetGlobalInt(11)==0) RunDialog(10);

In Dialog(0) one of the option 3 has:
run-script 2
Stop

in the dialog_request function in the global script there is this:
if (xvalue==2) {
string buffer;
InputBox ("PASSWORD",buffer);
if (buffer=="whatever the password is") {
SetGlobalInt(11,1);
}

The problem is probably with something in my scripting. If anyone can see it, PLEAAAASE help me.
Title: Re:using scripts in dialogs
Post by: Gilbert on Wed 03/09/2003 10:57:35
Quote
if (buffer=="whatever the password is") {

That is the problem. You cannot use '=', '==', '>', '<', etc. to assign or compare strings, instead, that line should be:

if (StrComp(buffer,"whatever the password is")==0) {
Title: Re:using scripts in dialogs
Post by: Babar on Wed 03/09/2003 11:17:31
It worked! It worked!  :) :) :) :) :)
Thank you Gilbot! Pardon my stupidty