skipTime – Talk
To explain my most recent edit: Previously I had put in the following:
A useful piece of code that will enable the mission to skip forward to any given time, irrespective of what time it happens to be in the mission is:
skipTime (_timeToSkipTo - daytime + 24 ) % 24
This was subsequently changed by Str to:
skipTime (-daytime + _timeToSkipTo)
That change was not correct.
To understand why this is the case imagine that _timeToSkipTo is 02:00 and that the current time in the mission is 23:30 (daytime = 23.50). In otherwords it is nearly midnight and you want to skip to the early hours of the next morning.
Using skipTime (_timeToSkipTo - daytime + 24 ) % 24 will work as follows:
_timeToSkipTo - daytime = -21.50
_timeToSkipTo - daytime + 24 = 2.50
(_timeToSkipTo - daytime + 24 ) % 24 = 2.5
So the mission will skip time 2.5 hours forward, which is correct.
Using skipTime (-daytime + _timeToSkipTo) will work as follows:
-daytime + _timeToSkipTo = -21.50
So the mission will skip backwards 21.5 hours, which is not correct.
Note that in the more simple case of _timeToSkipTo = 11.00 and daytime = 10.00
Then:
_timeToSkipTo - daytime = 1.0
_timeToSkipTo - daytime + 24 = 25.0
(_timeToSkipTo - daytime + 24 ) % 24 = 1.0
So it still works correctly.
--THobson 20:51, 13 August 2006 (CEST)
Oh sorry, I didn't noticed that % 24 and changed it to "correct" way. It is, but only until you want to skip to another day. My fault. --Str 21:38, 13 August 2006 (CEST)