When I wrote into the script
GetGraphicalVariable ("Strenght", +1);
Display ("You learn it!");
AGS announced me error (line 243) Parse error: unexpected operator "+".
What does it mean? :-\
GetGraphicalVariable (http://americangirlscouts.org/agswiki/Game_/_Global_functions#GetGraphicalVariable) only takes one parameter, the name of the variable. The proper syntax would be something like:
if (GetGraphicalVariable("Strength") == 1) Display("You learnt it!");
And mirek, what you'll probably want:
SetGraphicalVariable("Strength", GetGraphicalVariable("Strength")+1);
This will increase the variable by one.
Oh,thanks,I must learn how to use AGS right....
;)
Yeah, it may be a good idea to get to using the AGS scripting language, as then you can just declare a "Strength" variable in the script:
int strength = 10;
...and then simply do:
strength = strength + 1;
...or:
strength += 1;
...or even just:
strength ++;
...to increase the strength by one.
Using the graphical variables in text script makes that more unwieldy than necessary as you may see :)
Quote from: Scorpiorus on Tue 17/07/2007 16:48:41
Yeah, it may be a good idea to get to using the AGS scripting language, as then you can just declare a "Strength" variable in the script:
int strength = 10;
...and then simply do:
strength = strength + 1;
(edited for length)
I've run into problems when I try to do the same thing. I'm trying to declare some basic booleans that will be set and accessed at the beginning of the game (in character creation) and then read later on at key points in the game. For some reason I'm having a hard time accessing these variables from room scripts (pretty much the only place they'll be used) I've got a work around set up using a Properties mod I found on the forums, but I'm wondering if there's a better way to do this that I simply don't understand because it involves an aspect of variable scope that I'm not familiar with.
Basically... if you declared these variables at the top of your global script... how would you then access the variables from room scripts?
You have to export the variable in the global script and then import it in the room script in order to access it, so:
Global Script:
int blah;
export blah;
Room Script (OR the script header if you want it to be accessible from every room):
import int blah;
Ah...
Well that's much simpler... Somehow I got the impression that when you did that it redefined the variable to null... I suppose not though...
Thanks for the tip :D
P.S. One last question, do you need to export AFTER the variable has been set? Or will one export cause it to "live" outside the global script. Meaning its scope is outside the script yet it still needs to be imported.
Nevermind...
I've done some research... apparently you can export it right after it's declared and import it in the header file and all will be right with the world ;D
Thanks Gilbot
BFAQ entry on variables (http://americangirlscouts.org/agswiki/Scripting%2C_Code_%26_Interaction#Working_with_variables:_the_basics), for future reference.