device clock math-please help me understand

I understand that to set the clock u need to create 4 attributes ( sec, min, hr, yr) and constrain them to device.sec, etc. x their factors to make them all into sec. My objective is to make time base res/fuel production.
Question #1: How do get the game to save the initial time? I notice the device.sec goes back to 0 every 60 sec.
Question #2 What do the below math mean? I got this from the template. I think if I can just understand this , I can use it in my game.
180+( game.Clock.Hour + game.Clock.Minute /60+ game.Clock.Second /3600+ game.Clock.Millisecond /3600000)*15* self.TimelapseMultiplier
Question # 3 below is the contraint attribute for the watering in the template. Why is the minus (-2011) there for the clock.year and the minus (-1) for the month?
10*min(10,( game.Clock.Year -2011)*365*24*60*60+floor(( game.Clock.Month -1)*30.5)*24*60*60+( game.Clock.Day -1)*24*60*60+ game.Clock.Hour *60*60+ game.Clock.Minute *60+ game.Clock.Second + game.Clock.Millisecond /1000- self.Timestamp )
Thanks
update ( i think I figured it out) : the initial timestamp attribute is in the flower (scene 2) of the clock template . I used an display text to compare with my game so that I know it is correct
Question :
if the initial device clock set attribute is
initial
( game.Clock.Year -2011)*365*24+floor(( game.Clock.Month -1)*30.5)*24*60+( game.Clock.Day -1)*24*60+ game.Clock.Hour *60+ game.Clock.Minute + game.Clock.Second /60
and the after 4min change flower img is
-1.5+(( game.Clock.Year -2011)*365*24+floor(( game.Clock.Month -1)*30.5)*24*60+( game.Clock.Day -1)*24*60+ game.Clock.Hour *60+ game.Clock.Minute + game.Clock.Second /60)
Then the only difference is the "-1.5" , how do you get 4min out of "-1.5"? <<--- question
So if -1.5 = 4 min ( 240 Seconds) ..then -3.0 =8min..and -0.375= 1 min , right?
Question #1: How do get the game to save the initial time? I notice the device.sec goes back to 0 every 60 sec.
Question #2 What do the below math mean? I got this from the template. I think if I can just understand this , I can use it in my game.
180+( game.Clock.Hour + game.Clock.Minute /60+ game.Clock.Second /3600+ game.Clock.Millisecond /3600000)*15* self.TimelapseMultiplier
Question # 3 below is the contraint attribute for the watering in the template. Why is the minus (-2011) there for the clock.year and the minus (-1) for the month?
10*min(10,( game.Clock.Year -2011)*365*24*60*60+floor(( game.Clock.Month -1)*30.5)*24*60*60+( game.Clock.Day -1)*24*60*60+ game.Clock.Hour *60*60+ game.Clock.Minute *60+ game.Clock.Second + game.Clock.Millisecond /1000- self.Timestamp )
Thanks
update ( i think I figured it out) : the initial timestamp attribute is in the flower (scene 2) of the clock template . I used an display text to compare with my game so that I know it is correct
Question :
if the initial device clock set attribute is
initial
( game.Clock.Year -2011)*365*24+floor(( game.Clock.Month -1)*30.5)*24*60+( game.Clock.Day -1)*24*60+ game.Clock.Hour *60+ game.Clock.Minute + game.Clock.Second /60
and the after 4min change flower img is
-1.5+(( game.Clock.Year -2011)*365*24+floor(( game.Clock.Month -1)*30.5)*24*60+( game.Clock.Day -1)*24*60+ game.Clock.Hour *60+ game.Clock.Minute + game.Clock.Second /60)
Then the only difference is the "-1.5" , how do you get 4min out of "-1.5"? <<--- question
So if -1.5 = 4 min ( 240 Seconds) ..then -3.0 =8min..and -0.375= 1 min , right?
Best Answer
-
lukey5227 Posts: 111
Wow... um... Well, this could take 30 minutes to think about... What the hay... for horses...
Question 1: You're actually going to have seconds, minutes, hours, day, month, year
So if seconds is at 59, it won't go to 60. It'll go back to 0 and add one to the minute. Yep, it works like any other clock :P
If you want to know how long the game has been running, you can select Game.Time (which is in seconds) or unlock it and get Current Scene.Time which gives you the time you've been in that scene.
Question 2:
180+( game.Clock.Hour + game.Clock.Minute /60+ game.Clock.Second /3600+ game.Clock.Millisecond /3600000)*15* self.TimelapseMultiplier
Okay, I found it. This is EXACTLY what is happening:
First, the 180 is to start the sun/moon at night. See, all the stuff later will be equal to zero hours. Midnight. So we want it to start with the moon.
Now, a full rotation is 360 degrees. A full day is 24 hours. 360 ÷ 24 = 15. Thats why you multiply by 15. It'll go 15 degrees in one hour. Now, the reason for all the mess is because we need to put all the minutes seconds, ect, into an hour and a decimal. Suppose the minutes in 12. We now add that to our original 5 hours (game.Clock.Hour) which makes 5.2 a perfect number to multiply by 15 to get the angle.
So the Seconds/3600 converts it into a decimal of an hour. Same with Milliseconds.
Want it to go faster? If you make TimelapseMultiplier 24, your rotation will go 24 times faster. A rotation in one hour.
Overview: Convert into hour + decimal, add 180 to start at correct rotation, multiply by 15 for an hour and angle, and multiply by a time-lapse (so this will be 1 by default, one rotation for the thing in one day).
Question 3:
Not sure what the -2011 does. Maybe it saves space so it doesn't have to convert 2011 years into seconds?
Anyway, the -1 on the day and month are more common for computers, starting at 0 instead of 1 like us. Also, if you think about it: On January 4th, its been 4 days, 0 months. On February 4th, its been only 1 month and 4 days. We call it the seconds month, and it is, but only one has past.
Same with a day. It IS the 15th of December but 15 days of December haven't past until midnight on the 16th.
I'll get back to you on the last question later. Hope this helped!
Answers
I tested. After 1.5 minutes, the plant displays the "dead" image. So yes, 4 minutes later, the plant will still look dead :P