CC: Restitched

CC: Restitched

3M Downloads

`os.epoch()` results are not in milliseconds

ouroborus opened this issue · 6 comments

commented

Minecraft Version

1.18.x

Version

1.100.8

Details

The CC:Tweaked docs say that "ingame" is the default argument and that it produces the number of milliseconds since world creation. However, os.epoch() gives values that appear to be in 1/72nds of a millisecond.

Examples:

lua> a=os.epoch(); os.sleep(0.05); b=os.epoch(); c=b-a; print(c)
3600

0.05 seconds is 50ms or one tick, so the results in the example should be near 50.

lua> a=os.epoch("utc"); os.sleep(0.05); b=os.epoch("utc"); c=b-a; print(c)
38

Typical of actual game tick timing, but close to 50ms.

commented

can this be reproduced on 1.19 as well?
it wont matter either way but if it is reproducible on 1.19 then it would be useful to know. (same with #123 )

commented

Verified with 1.101.2 in 1.19.2

commented

This is actually the intended behavior. The "ingame" epoch is in-game time. There are 72 Minecraft days in one real-world day, so there are 72 Minecraft milliseconds in one real-world millisecond! Also, note that the "ingame" epoch freezes if you disable the world's daylight cycle. The "utc" and "local" options are available if you want wall clock time.

commented
commented

With the provided example CC: Tweaked produces the same result.

commented

Yeah, even the original ComputerCraft produces these results. Alright, then I'd say this is a documentation issue. CC:Tweaked just says it returns the results in milliseconds with no indication that these aren't real world milliseconds.