PDA

View Full Version : Question about state of variables



Richo the Dino
03-10-2010, 03:15 AM
So, is ASH a language whereby variables actually store an equation, and work out the current state at the moment?

To put it another way (from the MaxMp.ash script):

Suppose I have full mp...

mpFull = (my_mp() == my_maxmp());

.. and then I script to adventure a few times, casting saucegeyser.

Print ("Do I have full mana?: " + mpFull);

is this gonna work out the current state of MpFull (ie, false), or is it gonna remember the one figured out at the start of the script? I *had* thought that if you wanted a dynamic value, you'd have to use a subroutine.. this question is less about the actual example, more about my understanding of ASH..

Cheers
R

jasonharper
03-10-2010, 03:39 AM
No; a boolean variable (for example) stores a specific boolean value, set at the time the variable was most recently assigned.

Richo the Dino
03-10-2010, 03:57 AM
Ok, thanks. Just checking :o)

heeheehee
03-10-2010, 05:28 AM
You can, however, totally do this with user-defined functions.
So, for instance:

boolean mpFull () {
if(my_mp() == my_maxmp()) return true;
return false;
}
And then a bit of code for testing... if(!mpFull()) print(Your MP is not full!);

adeyke
03-10-2010, 05:50 AM
Or:

boolean mpFull () {
return (my_mp() == my_maxmp());
}

:p

heeheehee
03-10-2010, 06:01 AM
Yeah, that would totally work. I'm just tired. =P