TangerineDog Posted October 2, 2017 Share Posted October 2, 2017 I noticed that when I set a timer to, say, 0.4, it always ends up registering at something like 0.3993 or 0.4113, never at 0.4 exactly.Which kinda bums some of my scripts. So how exact is game time? How can I set a timer that runs 0.4 hours exactly - and can I do it at all? Link to comment Share on other sites More sharing options...
Kapteyn Posted October 2, 2017 Share Posted October 2, 2017 (edited) Try getting pi using a float and then come back with that question. :smile: Basically, Skyrim works based on days, not hours. So the floating point of one hour is equivalent to 1/24 - so 24 minutes is equivalent to 1/60. Once you start hitting so many decimal points it becomes inaccurate (probably 15 places, it is with JavaScript anyway). If pinpoint accuracy is expected then you end up with situations like scud missiles not being intercepted... On February 25, 1991, an Iraqi Scud hit the barracks in Dhahran, Saudi Arabia, killing 28 soldiers from the U.S. Army's 14th Quartermaster Detachment.A government investigation revealed that the failed intercept at Dhahran had been caused by a software error in the system's handling of timestamps. The Patriot missile battery at Dhahran had been in operation for 100 hours, by which time the system's internal clock had drifted by one-third of a second. Due to the missile's speed this was equivalent to a miss distance of 600 meters.The radar system had successfully detected the Scud and predicted where to look for it next. However, the timestamps of the two radar pulses being compared were converted to floating point differently: one correctly, the other introducing an error proportionate to the operation time so far (100 hours) caused by the truncation in a 24-bit fixed-point register. As a result, the difference between the pulses was wrong, so the system looked in the wrong part of the sky and found no target. With no target, the initial detection was assumed to be a spurious track and the missile was removed from the system. No interception was attempted, and the Scud impacted on a makeshift barracks in an Al Khobar warehouse, killing 28 soldiers, the first Americans to be killed from the Scuds that Iraq had launched against Saudi Arabia and Israel.Two weeks earlier, on February 11, 1991, the Israelis had identified the problem and informed the U.S. Army and the PATRIOT Project Office, the software manufacturer. As a stopgap measure, the Israelis had recommended rebooting the system's computers regularly. The manufacturer supplied updated software to the Army on February 26.There had previously been failures in the MIM-104 system at the Joint Defense Facility Nurrungar in Australia, which was charged with processing signals from satellite-based early launch detection systems Edited October 2, 2017 by Kapteyn Link to comment Share on other sites More sharing options...
foamyesque Posted October 2, 2017 Share Posted October 2, 2017 (edited) I noticed that when I set a timer to, say, 0.4, it always ends up registering at something like 0.3993 or 0.4113, never at 0.4 exactly.Which kinda bums some of my scripts. So how exact is game time? How can I set a timer that runs 0.4 hours exactly - and can I do it at all? The time is pretty precise, but when your script will execute is not. Scripts get their runtime and resources managed by a VM, and so depending on how many other things are going on there can be noticeable variations from what you asked for and what you get. The very act of calling the function to check the time takes time, for example. Likewise outputting the result into a logfile. Edited October 2, 2017 by foamyesque Link to comment Share on other sites More sharing options...
Kapteyn Posted October 2, 2017 Share Posted October 2, 2017 Oh, so it's latency. But there is still the issue of the accuracy of floating points. Link to comment Share on other sites More sharing options...
TangerineDog Posted October 2, 2017 Author Share Posted October 2, 2017 (edited) Yeah, latency sounds kinda like the problem in that case.Edit: but just to be clear - it is latency in the common sense and it will never happen that a script triggers too early? Edited October 2, 2017 by TangerineDog Link to comment Share on other sites More sharing options...
Kapteyn Posted October 3, 2017 Share Posted October 3, 2017 If you're trying to fire a script at a certain time of the day then it won't be accurate, not only because of latency but also due to floating point limitations. The best I understand it is like this... To get the current hour of the day... say the current day is 31 and it's exactly noon, then the current time is 31.5 so far as the game is concerned. So to get a useable hour of the day in 24-hour format, you remove the 31 (using math floor) and multiple the remaining decimal by 24, which obviously gives 12. That's great, you'll have no problem finding the hour but if you're looking for minutes, even seconds then you're going to have problems. Simple timers, that's just about latency... checking against the game time is a different matter. Link to comment Share on other sites More sharing options...
Recommended Posts