Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: viktor on Sun 05/09/2004 21:02:16

Title: dialogs- solved
Post by: viktor on Sun 05/09/2004 21:02:16
I hawe a dialog with 2 responses. The character can say for instance no and the game ends. Or the character can say yes and the game continous. How do I make that? I know this has been asked before and I'm sory for posting again but I didn't understand anything in that topic. Could someone please help me.
Title: Re: dialogs
Post by: SilverWizard_OTF on Sun 05/09/2004 21:13:02
I hope you know about dialog_request function and how to use it with the dialog script editor.

IF character tells "no", to dialog's script editor, after "no" option, type
run-script  X (where X is a number, and should be over 100).

now to the global script:

function dialog_request(int param) {
   if(param==100) {
       QuitGame(0);
        }
    }

"QuitGame" is  a command that tells game to exit.   (0 means it exits without warning and 1 means it  asks player if he wants to quit).

That's all.
Did i help a bit?
Title: Re: dialogs
Post by: Proskrito on Sun 05/09/2004 23:05:25
a little off-topic: why over 100? any integer should work, shouldnt it?
Title: Re: dialogs
Post by: Goldsmith on Mon 06/09/2004 01:44:05
Well, it does work with any integer, and I really don't see why it shouldn't be under 100.
Title: Re: dialogs
Post by: Edwin Xie on Mon 06/09/2004 01:57:54
I agree, why shouldn't it be under 100?

Anyway, I may be able to help you, maybe with an easier way. Now from the manual there is a line that explains function dialog_request:
Quote
dialog_request (int parameter)
Called when a dialog script line "run-script" is processed. PARAMETER is the value of the number following the "run-script" on that line of the dialog script.

Now in the dialog script, lets say the first option is "yes" and the second option is "no". Just type in the dialog script:

// dialog script file
@S  // dialog startup entry point
narrator: "Do you want to continue the game?"
@1  // option 1
stop
@2  // option 2
run-script 1

Now, in the global script, just type


function dialog_request (1){
   if(param==1) {
       QuitGame(0);
        }
    }

Title: Re: dialogs
Post by: viktor on Mon 06/09/2004 13:35:49
Quote from: Edwinxie on Mon 06/09/2004 01:57:54
I agree, why shouldn't it be under 100?

Anyway, I may be able to help you, maybe with an easier way. Now from the manual there is a line that explains function dialog_request:
Quote
dialog_request (int parameter)
Called when a dialog script line "run-script" is processed. PARAMETER is the value of the number following the "run-script" on that line of the dialog script.

Now in the dialog script, lets say the first option is "yes" and the second option is "no". Just type in the dialog script:

// dialog script file
@S  // dialog startup entry point
narrator: "Do you want to continue the game?"
@1  // option 1
stop
@2  // option 2
run-script 1

Now, in the global script, just type


function dialog_request (1){
   if(param==1) {
       QuitGame(0);
        }
    }



where in the global script do I tipe that in?
Title: Re: dialogs
Post by: Scorpiorus on Mon 06/09/2004 14:36:37
Say, at the top of the main global script:

// main global script file

function dialog_request (int parameter) {

Ã,  Ã,  if (parameter == 1)
Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã, QuitGame(0);
Ã,  Ã,  }
}


In the dialog script:

// dialog script file

@SÃ,  // dialog startup entry point
narrator: "Do you want to continue the game?"
return
@1Ã,  // option 1 YES
stop
@2Ã,  // option 2 NO
run-script 1
stop



As for which number to use it doesn't really metter, you can use any within the range:
-2147483648....2147483647.

But...

If you're not sure whether you will be using a parser input in dialog feature it is recommended to use greater values, since if you'll decide to have parser in dialog then to provide the necessary control AGS will be passing a topic number as parameter to the dialog_request function and there a conflict may happen. Better be safe than sorry :)

QuoteParser input

You'll notice in the dialog editor, a checkbox "Show text parser with this topic". If you check this, a text box is displayed below the predefined options, which allows the player to type in their own input.

If they type in something themselves, then the dialog_request global script function will be run, with its parameter being the dialog topic number that the player was in.

AGS automatically calls ParseText with the text they typed in before it calls dialog_request, so you can use Said() calls to respond. See the text parser section for more info.
Title: Re: dialogs
Post by: SilverWizard_OTF on Mon 06/09/2004 17:31:17
Well, even a Wizard may be confused with something else, and give a muddy answer.

Yes, you have right, there is no reason to use a number over 100.
Title: Re: dialogs
Post by: Scorpiorus on Mon 06/09/2004 17:46:46
QuoteYes, you have right, there is no reason to use a number over 100.
There is, actually. See my previous post. ;)


[edit: to fix "these is" to "there is"]
Title: Re: dialogs
Post by: viktor on Mon 06/09/2004 19:08:21
thanks for the help. Now it works. :D
Title: Re: dialogs- solved
Post by: SilverWizard_OTF on Mon 06/09/2004 20:39:42
I knew that, that's why i had in my mind that i should use greater values on Run-script.
   But i haven't used text parser for a long time, so i forgot that.
Thanks for your pointer,  Scorpiorous.