Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ncw14 on Wed 19/12/2007 00:10:07

Title: Givescore
Post by: ncw14 on Wed 19/12/2007 00:10:07
I have a game based on southpark, my HP on gui is same as score - i have a problem, i already have hp as both
Givescore (100);
SetGlobalInt (1, 100);

if i erase either my scripts will make no scence.

is there a way in script to say something like

Givescore = SetGlobalInt (1, 100);

or how would i write the operation 

Givescore (+20);
      it doesnt accept it, how do i add 20 to givescore
Title: Re: Givescore
Post by: Ashen on Wed 19/12/2007 10:22:11
Go back and read the manual entries for SetGlobalInt and GiveScore (along with everything else on variables you can find). They're two quite different functions. SetGlobalInt, as the name suggests, SETS the Global Int to whatever value you input; GiveScore on the other hand ADDS the value you input to the current score. So, the two lines you quote:

GiveScore (100);
SetGlobalInt (1, 100);

Aren't actually doing the same thing.

What are you asking? Because the obvious answer to "how do i add 20 to givescore" is GiveScore(20); - as it says in the manual. (The current score is the game.score variable, but you can't set that directly.)
The way to ADD to a Global Int would be SetGlobalInt(1, GetGlobalInt(1)+20); - which isn't in the manual, but is in the BFAQ (http://americangirlscouts.org/agswiki/Scripting%2C_Code_%26_Interaction#GlobalInts.2C_your_friend:_what_they_are_and_how_to_use_them).