Adding relative +1

Started by InCreator, Sun 20/06/2004 03:29:56

Previous topic - Next topic

InCreator

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?

Ashen

SetGlobalInt (100, GetGlobalInt(100)+1);
I know what you're thinking ... Don't think that.

InCreator

Oh, It goes the long way. Thanks.

Scorpiorus

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

SMF spam blocked by CleanTalk