Variable change with dialog.

Started by sloppy, Thu 03/11/2005 03:45:28

Previous topic - Next topic

sloppy

This is basic I know, but I can't figure it out. 
I've declared an int called int speak_leonproof;
export speak_leonproof;

A character wants proof before he gives me a key to a building.  When he asks me for proof in the dialog,
When speak_leonproof=1
then I can retieve a document showing proof.
How do I change the variable of speak_leonproof in the dialog?

Ubel

You have to use dialog request.

Put this to your Global Script:

Code: ags

#sectionstart dialog_requestÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function dialog_request(int parameter) {
Ã,  if (parameter==1) {
Ã,  Ã,  speak_leonproof=1;
Ã,  }
}
#sectionend dialog_requestÃ,  // DO NOT EDIT OR REMOVE THIS LINE


Then put this to your dialog script:

Code: ags

run-script 1


This will execute the script under the parameter 1.

It all may be quite complicated to understand if you're new to scripting. So don't worry, it took quite a some time for me to understand how it works when I started.

Gilbert

Or, use the globalints, you can set their value directly from within a dialog script, unfortunately, it seems you still can't check their value and jump to branches directly within a dialog.

sloppy

Okay, the dialog request worked.  Now what do you do if there's a second variable change in another dialog?

I've got a variable called speak_leonsecondproof.
In the Global Script do you put it in the same function as the first and say if (parameter==2)?
How would the second variable be changed?

Ubel

Yes, use the same code I gave you but add the parameter 2 thing after the parameter 1 code. Remember to put it in the same dialog_request function.
Code: ags

Ã,  if (parameter==2) {
Ã,  Ã,  speak_leonsecondproof=1;
Ã,  }


and then use this in the dialog:
Code: ags
run-script 2

SMF spam blocked by CleanTalk