Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: scottmmmm on Wed 27/07/2005 21:35:56

Title: How to manipulate variables from dialogs?[SOLVED!!!]
Post by: scottmmmm on Wed 27/07/2005 21:35:56
Hi,
I need to make the value of a variable change when a particular option is selected in a dialog so that I can proceed to pick an item up.

i.eÃ,  Ã,  Ã,  Ã, "OK you can take my hook"
*variable changes to 1*
Hook can now be picked up from floor

I'v tried dialog requests but I cant get them to work, if this is the right way to do this could someone tell me exactly how to use this function or if there is a better way please let me know.

thanks,
Scott
Title: Re: Problem with manipulating variables through dialog
Post by: strazer on Wed 27/07/2005 22:07:36

// dialog script

//...

@3 // option 3
man: Ok, you can take my hook.
run-script 27
stop

//...



// global script

int thevariable = 0; // define global variable
export thevariable; // export variable for use in room scripts


function dialog_request(int parameter) {

  if (parameter == 27) { // if "run-script 27" used

    thevariable = 1; // or whatever

  }
//else if (parameter == xx) {

}



// main script header

import int thevariable; // import the variable for use in room scripts


Edit:

If you're talking about GlobalInts, you can set them directly by using the set-globalint GI VAL command, e.g.
  set-globalint 8 1
instead of the run-script command.

You can change the graphical variables used by the interaction editor via the SetGraphicalVariable function.
Title: Re: How to manipulate variables from dialogs? [SOLVED]
Post by: scottmmmm on Mon 01/08/2005 22:42:11
I cant get this solution to work, I've manipulated the variable names etc to get it to work in my script but it doesnt work, the variable is not changing value. any suggestions?
Title: Re: How to manipulate variables from dialogs?
Post by: strazer on Tue 02/08/2005 05:28:22
Put a Display command in the dialog_request function to see if it is called at all.
Title: Re: How to manipulate variables from dialogs?
Post by: scottmmmm on Tue 02/08/2005 14:55:38
Yeah the dialog request is definately getting called, I think the problem must be with my conditional statements in the room that the object is in. I have been using the editor to do a conditional statement on the variable but i think i must be doing it wrong because ive been creating a new variable form scratch, I get the feeling that its testing the wrong variable. How do you use the variable after youv exported it?
Title: Re: How to manipulate variables from dialogs?[SOLVED!!!]
Post by: scottmmmm on Tue 02/08/2005 15:49:59
Hurrah!!
I fixed it, I was using Global Variables in the script and Graphical Variables in the Room.

Thanks alot for yor help Strazer I learned alot from this problem, you da man

;D
Title: Re: How to manipulate variables from dialogs?
Post by: monkey0506 on Tue 02/08/2005 17:25:07
Quote from: scottmmmm on Tue 02/08/2005 14:55:38
Yeah the dialog request is definately getting called, I think the problem must be with my conditional statements in the room that the object is in. I have been using the editor to do a conditional statement on the variable but i think i must be doing it wrong because ive been creating a new variable form scratch, I get the feeling that its testing the wrong variable. How do you use the variable after youv exported it?


Strazer already answered that further up, but you use have to import it first like:

import var_type var_name;

Then you can use it just like you would a regular variable.  Of course var_type would be the type (int, char, etc.), and var_name would be the name.