How to manipulate variables from dialogs?[SOLVED!!!]

Started by scottmmmm, Wed 27/07/2005 21:35:56

Previous topic - Next topic

scottmmmm

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

strazer

#1
Code: ags

// dialog script

//...

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

//...


Code: ags

// 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) {

}


Code: ags

// 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.

scottmmmm

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?

strazer

Put a Display command in the dialog_request function to see if it is called at all.

scottmmmm

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?

scottmmmm

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

monkey0506

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:

Code: ags
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.

SMF spam blocked by CleanTalk