formula for multiples of 60 in "if" statement in rule?

developer6810developer6810 Member Posts: 139
edited July 2012 in Working with GS (Mac)
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.

Best Answer

  • MarkOnTheIronMarkOnTheIron Posts: 1,447
    Accepted Answer
    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

  • ORBZORBZ Member Posts: 1,304
    edited July 2012
    when game.time % 60 = 0

    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
  • developer6810developer6810 Member Posts: 139
    @MarkOnTheIron

    What do you mean by "scene control" actor?
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    @developer6810 I always have one in my games. It's an actor that I create and put in every scene. I usually use it to control various things from levels setup to achievements to scene changing.

  • developer6810developer6810 Member Posts: 139
    @MarkOnTheIron

    Ah. Thanks. Great idea!
  • developer6810developer6810 Member Posts: 139
    @MarkOnTheIron

    So if I use the same actor on each scene, even if the player changes or resets the scene, the "timer" won't reset?
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    The self.Time attribute of an actor is active only if the actor is present in a scene and even if you use the same actor in different scenes it will reset at each change of scene.

    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.

  • developer6810developer6810 Member Posts: 139
    What exactly would be the set of rules necessary for the game.Time attribute?
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    The exact same as the one I posted before. Just change the self.Time attribute with the game.Time attribute.

Sign In or Register to comment.