How to make an attribute change every 24 hours
carlblanchet
Member Posts: 755
Hey all!
Just checking if this is even possible, but I would like to implement in my game a collect coins button that destroys itself when collected and spawns back 24 hours later.
The first way for making this that came to my mind would be to have the collectButton actor: when pressed, destroy actor, change attribute Collected to true. Then have a spawner actor: when attribute Collected is true, after 86,400 seconds (lol) change attribute Collected to false / when attribute Collected is false, spawn collectButton actor.
The thing about this is that the timer probably doesn't countdown when the app is closed... or does it?
Do you know any other way of accomplishing this?
Thanks a lot!
Just checking if this is even possible, but I would like to implement in my game a collect coins button that destroys itself when collected and spawns back 24 hours later.
The first way for making this that came to my mind would be to have the collectButton actor: when pressed, destroy actor, change attribute Collected to true. Then have a spawner actor: when attribute Collected is true, after 86,400 seconds (lol) change attribute Collected to false / when attribute Collected is false, spawn collectButton actor.
The thing about this is that the timer probably doesn't countdown when the app is closed... or does it?
Do you know any other way of accomplishing this?
Thanks a lot!
Comments
So I created a self index attribute that I called 'Day', and a boolean attribute that I called 'DailyButtonPressed'. Then added the rules:
(Both attributes are loaded)
~If attribute DailyButtonPressed is True~
-Destroy-
~WHEN TOUCH IS PRESSED~
-Change self.Day to game.clock.day-
-Change DailyButtonPressed to True-
-Destroy-
~WHEN TOUCH IS RELEASED~
-Save attribute DailyButtonPressed-
-Save attribute self.Day-
~If attribute self.Day is not equal to game.clock.day~
-Change DailyButtonPressed to false-
With all this implemented, every time I leave the scene and come back, the button reappears. Can anyone see why this isn't working?
Thanks!