Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: InCreator on Sun 20/06/2004 03:29:56

Title: Adding relative +1
Post by: InCreator on Sun 20/06/2004 03:29:56
How does it work in AGS scripts? I have to add relative value of +1 to Globalint and can't get the code right.

SetGlobalInt(100)++; won't work.

How to code this right?
Title: Re: Adding relative +1
Post by: Ashen on Sun 20/06/2004 03:31:05
SetGlobalInt (100, GetGlobalInt(100)+1);
Title: Re: Adding relative +1
Post by: InCreator on Sun 20/06/2004 03:35:06
Oh, It goes the long way. Thanks.
Title: Re: Adding relative +1
Post by: Scorpiorus on Sun 20/06/2004 14:27:14
QuoteOh, It goes the long way.

You can write a function to make life easier:

function AddGlobalInt(int GINumber, int valueToAdd) {

   SetGlobalInt(GINumber, GetGlobalInt(GINumber) + valueToAdd)
}

So:

AddGlobalInt(100, 1); // will increase GI100 by 1