How to use real time to set a timer?

WeiyuWeiyu Member Posts: 216
edited January 2018 in Working with GS (Mac)

I made a Energy System which player will consume one point energy when he/she enter any levels.
And every 30 minutes, the Energy System will restore 1 point energy.

# But!!!!!
I have no idea how to set timer by real time.

For excample: The player consumed one point energy in 5:25A.M. And he/she can restore 1 point energy in 5:55A.M.(Whether he/she open my game or not, he/she will restore one point energy every 30 minutes.)

Could someone teach me how to set real timer, please?
Thank you. :'(

Comments

  • awesome_wellsawesome_wells Member, PRO Posts: 38
    edited January 2018

    Hi @Weiyu.

    You can use the Devices>Clock to set up a group of attributes (e.g 'System Timer Hours', 'System Timer Minutes' etc..) when the player starts a game.

    Now you can create an 'Add Energy' rule that compares Game.clock to 'Energy System Timer' to add a point of energy per 30 mins that has passed. Once the energy has been added you then set the 'System Timer' attributes again to the current Device>Clock.

    I hope that helps!

  • WeiyuWeiyu Member Posts: 216
    edited January 2018

    @awesome_wells said:
    Hi @Weiyu.

    You can use the Devices>Clock to set up a group of attributes (e.g 'System Timer Hours', 'System Timer Minutes' etc..) when the player starts a game.

    Now you can create an 'Add Energy' rule that compares Game.clock to 'Energy System Timer' to add a point of energy per 30 mins that has passed. Once the energy has been added you then set the 'System Timer' attributes again to the current Device>Clock.

    I hope that helps!

    Thank you for your reply.
    But I'm very sorry, I still can't understand how to use real time to set a timer.

    I tried to make a template by your said.
    But it still incomplete, I'm sorry I'm not smart.. :'(

  • awesome_wellsawesome_wells Member, PRO Posts: 38

    Hi again @Weiyu.

    I've attached a quick game timer that works as I described. Push the red box to start timer.

    It counts total seconds since timer is started. The date/time that the timer is started is a saved attribute so you can use the GameSalad viewer to test on a device.

    The limitation is that when the month changes, the day calculation becomes inaccurate. It can be solved but the rules become more complex because of course not all months have same amount of days. But I figure for your needs, energy levels will be fully restored after 1 day regardless.

    I hope this helps!

  • awesome_wellsawesome_wells Member, PRO Posts: 38

    Actually, sorry, there was a bug when the day changes!

    This version should work correctly over multiple days (though when month changes, timer assumes 30 day month).

  • WeiyuWeiyu Member Posts: 216

    @awesome_wells said:
    Actually, sorry, there was a bug when the day changes!

    This version should work correctly over multiple days (though when month changes, timer assumes 30 day month).

    Wooow!! This is amazing!!
    Thanks for your help.
    I really appreciate what you've done for me. <3 <3

  • Hi, do you still got the demo??

    thanks!

  • realworthygamesrealworthygames Member Posts: 31

    I would like this too please as I've been struggling since last year September. I couldn't get the lives timer to work. :(

Sign In or Register to comment.