static bool Game.DoOnceOnly(const string token)
This function gives you an easy way of making some code run only the first time that
the player encounters it. It is commonly used for awarding points.
The token parameter is an arbitrary string. You can pass whatever you like in
for this, but IT MUST BE UNIQUE. It is this string that allows AGS to determine
whether this section of code has been run before, therefore you should make sure
that you do not use the same token string in two different places in your game.
Returns true the first time that it is called with this token, and false thereafter.
NOTE: This is a static function, and thus need to be called with Game. in front of it. See
the example below.
Example:
if (Game.DoOnceOnly("open cupboard")) {
GiveScore(5);
}
will give the player 5 points the first time this script is run.
See Also: GiveScore
|