1. Can someone tell me if it's possible to add the value of two variables together within the script?
2. I see there are variables, such as @GIx@, and the @SCORE@ variables that can be put into messages and will display your current score, or whatever, but are there such variables that you can use to plug a character's name, or an inventory item's name into a message.
3. One last thing, I declare my globalints/variables in the script header, correct?
Quote(If the variable is smaller than or equal to 10, but greater than or equal to 7, then do this...)
You just combine two conditions (AND expression), like this:
if ( (variable >= 7) && (variable <= 10)) {
//code
}
An OR expression would use || instead of &&
QuoteI see there are variables, such as @GIx@, and the @SCORE@
I knew about @SCORE@ and so forth, but where did you read about @GIx@? Didn't know that and I couldn't find it in the manual.
QuoteOne last thing, I declare my globalints/variables in the script header, correct?
AFAIK the script header covers (all) rooms only, don't know if the variables work in the global script then.
I define my variables in the global script
int variable;
then I export it at the end of the global script
export variable;
then import them in the script header
import int variable;
This way, the variable is available in both global script and in all rooms.
Sure, it's in the manual under "Setting Up The Game".
This is what it reads:
token replaced by
@INx@ number of inventory item x that the player has
@GIx@ the current value of GlobalInt x (used with SetGlobalInt/GetGlobalInt)
There are those variables, as well as "%s" and a few others I can't quite remember or find.
What about adding the values of two variables? Do you know anything about that?
QuoteSure, it's in the manual under "Setting Up The Game".
Ah yes, thanks.
QuoteWhat about adding the values of two variables? Do you know anything about that?
Don't quite know what you mean. Doesn't
variable3 = variable1 + variable2;
work?
Correct. I wasn't aware that AGS could do something like that. I didn't see it in the manual, so I just thought I'd ask. (but I feel like a dumbshit now... :()
Thanks for the help. ;)
Anytime, pal :)
Okay, I've been reading through the manual for about an hour now, and I just can't seem to find exactly what I've done wrong here....
function game_start() {
// called when the game starts, before the first room is loaded
SetInvDimensions(49,49);
int jim_health = 10;
}
function repeatedly_execute() {
// put anything you want to happen every game cycle here
* if ((jim_health <= 10) && (jim_health >= 7)){
AnimateButton (STATUSBAR,0,8,0,2,1);
AnimateButton (STATUSBAR,1,9,0,2,1);
}
if ((jim_health <= 6) && (jim_health >= 4)){
AnimateButton (STATUSBAR,0,8,1,2,1);
AnimateButton (STATUSBAR,1,9,1,2,1);
}
if ((jim_health <= 3) && (jim_health >= 1)){
AnimateButton (STATUSBAR,0,8,2,2,1);
AnimateButton (STATUSBAR,1,9,2,2,1);
}
if (jim_health == 0){
AnimateButton (STATUSBAR,0,8,3,2,1);
AnimateButton (STATUSBAR,1,9,3,2,1);
}
}
The * is where this error message comes up when I test the game:
Error (line 11): undefined symbol 'jim_health'
The writing in bold is the script I'm trying to make work. I didn't know where to declare my variables, so I just declared them in the same area as SetInvDimensions.
Any ideas?
Put that variable declaration line of jim_health outside of game_start() function, otherwise it will be declared within the function and destroyed when the function ended.
So just put the line:
int jim_health = 10;
ON TOP OF the global script, OUTSIDE any functions, and it should work.
The special codes like @GIx@ and @OVERHOSTPOT@ are largely redundant now. The recommended method is to use StrFormat to include whatever variables you want.
For example,
string buffer;
StrFormat(buffer, "Your name is %s.", character[EGO].name);
SetLabelText(STATUSBAR, 1, buffer);