again variables

Started by miguel, Sun 08/06/2003 12:36:24

Previous topic - Next topic

miguel

hello to all,

when I use the editor to set a variable value (naming it and giving it a value;ie, MYVAR=5)  is it not the same as writing "int MYVAR = 5" in scripting?; If so, if I change it's value in scripting it should change it's value.
My problem is, I have a Repeatedly_EXecute function that is called if MYVAR=5 but when I change it's value I would want that the function stoped running.
Is it because it's under Repeatedly_Execute? How do I make it work?

I tryed, (Rep_Exec):
  - Conditional - if a var. is set to a cert. val (MYVAR=5)
    run script;
  - Conditional - if a var. is set to a cert. val (MYVAR=6)
    stop running more comands;
but it doesn't work either

thanks for all the help
Working on a RON game!!!!!

Captain Mostly

perhaps

if(MYVAR==6)
{
//don't do anything
}
else
{
MYVAR = 5;
}


that means that if my var is anything except 6, it'll be repeatedly changed back to 5

miguel

well it doesn't reconize the variable,
"undefined symbol MYVAR"
should I import it? I should not because it was created on the same room.(?)
don't know what to do, here's my script:
//
function room_d() {
 // script for room: Repeatedly execute

if (myvar==6) {
}
else {scratch();}
 
}
-----------------------------------
also, myvar was "created" inside a interact function and it 's value is changed inside a object function,
is it because of that?
Working on a RON game!!!!!

scotch

Yeah maybe, because MYVAR is only created whn the interaction is run I guess.
Try declaring it at the top of your room script.

miguel

I did that just now but still it didn't work, but I found what it was, I just changed this:
I had Conditional - Set Variable Val...(MYVAR=5)
  and changed it to a script line:
myvar=5;

and it works now(?), why is it?

thanks captain and scotch
Working on a RON game!!!!!

Scorpiorus

Not sure what you are asking of, but the variable created via the interaction editor is different than one defined in the script. Variable created in the editor can have a name containing space chars for example: got the key etc.
So if you want to access an interaction editor variable in the script look for GetGraphicalVariable() in the manual:

GetGraphicalVariable (string variable_name);

Returns the value of the interaction editor VARIABLE_NAME variable. This allows your script to access the values of variables set in the interaction editor.
Example:

if (GetGraphicalVariable("climbed rock")==1)
  { code here }


will execute the code only if interaction variable "climbed rock" is 1.

Quotejust changed this:
I had Conditional - Set Variable Val...(MYVAR=5)
and changed it to a script line:
myvar=5;
Yep, and thereby you chaged the value of the script variable, not interaction (graphical) variable.


hope it what you need

-Cheers

miguel

Now I understand, I didn't know of GetGraphicalVariable, but it makes sense now,
thanks a lot for the explanation because I'm sure I would be asking questions about variables again soon but now I'm getting the picture,
thanks scorpiorus
Working on a RON game!!!!!

SMF spam blocked by CleanTalk