Page 1 of 1
EventData "tick" field should be uint64 type
Posted: Fri Mar 13, 2026 5:37 pm
by Shemp
Since
game.tick is represented in the API as being 64-bit, and I've been told that the tick count is never intentionally truncated to 32-bits before being passed to events, all mentions of the "tick" field
here and
here should say that they're using the uint64 type.
The reason that I even thought to bring this up is that 2^32 game ticks is about 2.25 years of in-game time, which is a very extreme amount of time to be playing one save but is still realistically possible, and modders thankfully don't need to worry about the tick count overflowing.
Re: EventData "tick" field should be uint64 type
Posted: Sun Mar 15, 2026 5:41 am
by quyxkh
lua5.2 numbers are iee754 doubles, which can represent exact integers up to 53 bits.
lua5.2 doesn't *have* a uint64 type, so you're kind of out of luck.
Fortunately, 2^53 ticks is more than two million years. Much more.
Re: EventData "tick" field should be uint64 type
Posted: Sun Mar 15, 2026 6:42 am
by Osmo
quyxkh wrote: Sun Mar 15, 2026 5:41 am
lua5.2 numbers are iee754 doubles, which can represent exact integers up to 53 bits.
The docs should still say it is uint64 regardless because that's what it is. And in fact, there's even a type MapTick which is a uint64, and it is documented on uint64 page that lua cannot represent it. Its just not used everywhere that ticks are supposed to be used.
https://lua-api.factorio.com/latest/con ... pTick.html
I do wonder though if uint32 is actually used in most prototype definitions or its just a docs error.
There are some things that use MapTick, but a bunch of things that represent ticks use uint32. Just searching for "tick" on prototype docs, most results seem to be uint32. Though searching for "tick" and "time" on
uint32 page is probably the fastest way to find them all.
Re: EventData "tick" field should be uint64 type
Posted: Sun Mar 15, 2026 5:48 pm
by quyxkh
Ah. I get it now, the problem is it's *documented* to be passed as a uint32, and if the code's doing what the docs imply it'll wrap the event tick a few million years before game.tick starts getting wonky. My bad, it makes so little sense that it'd actually do that truncation I couldn't see it even looking right at it. Maybe they've got a special prize in the code for anybody who gets a map that far? That'd be funny anyway.