cc-tweaked / cc-restitched

Other
80 stars 33 forks source link

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

Closed ouroborus closed 1 year ago

ouroborus commented 1 year ago

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.

Merith-TK commented 1 year ago

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 )

ouroborus commented 1 year ago

Verified with 1.101.2 in 1.19.2

toad-dev commented 1 year ago

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.

Merith-TK commented 1 year ago

What I think they meant was that epoch is not returning it in the same way CC;T does

On Sun, Sep 4, 2022, 6:28 PM toad-dev @.***> wrote:

Closed #124 https://github.com/cc-tweaked/cc-restitched/issues/124 as completed.

— Reply to this email directly, view it on GitHub https://github.com/cc-tweaked/cc-restitched/issues/124#event-7319248496, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPQOXRQVVBOQVDUZ5TAHJ3V4VEE7ANCNFSM6AAAAAAQBZKHYA . You are receiving this because you commented.Message ID: @.***>

toad-dev commented 1 year ago

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

ouroborus commented 1 year ago

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.