formula for multiples of 60 in "if" statement in rule?
![developer6810](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
I want an autosave feature so basically I added:
timer: every 1 second, change game.SaveTime to game.SaveTime+1
rule: if ANY: game.SaveTime = (I want multiples of 60 to infinity), then SAVE
__________________________
Anyone know what formula I could use to make an infinite number of "if" statements?
Thanks.
timer: every 1 second, change game.SaveTime to game.SaveTime+1
rule: if ANY: game.SaveTime = (I want multiples of 60 to infinity), then SAVE
__________________________
Anyone know what formula I could use to make an infinite number of "if" statements?
Thanks.
Best Answer
-
MarkOnTheIron Posts: 1,447
So, if I understand correctly you want a Save Attribute to fire every 60 seconds?
What I would do is to have it on a SceneControl actor. In that actor I would add a self attribute called Mod (or whatever you prefer) and give it a value of 0. Then I would add a rule that says:
When attribute Mod is equal (=) to self.Time%60
--Save Attribute
That way you will fire the Save Attribute every 60 seconds without using any timers because you will use the default Time attribute of the actor.
Answers
but... since GS requires that the left hand side of a rule be a variable you need to create a game variable called Zero that equals ... well, 0
when game.zero = game.time % 60
That rule will fire every 60 seconds.
However, wouldn't a timer just be simpler?
Every 60s ...
Lol, I just read the post above mine. @MarkOnTheIron is correct
What do you mean by "scene control" actor?
Ah. Thanks. Great idea!
So if I use the same actor on each scene, even if the player changes or resets the scene, the "timer" won't reset?
If you want a time attribute that's continuos throughout the game and that won't reset (except when the game is quitted) then you can use the game.Time attribute.