FFF 388 announced engine support for ticks up to 2^64, but only Lua support for ticks up to 2^52.
We can work around the Lua limit by breaking up the tick into two 32-bit numbers. The upper 32 bits are easy to calculate from LuaGameScript.tick. But we need a new property that contains the lower 32 bits. Call it LuaGameScript.small_tick.
LuaGameScript.small_tick
Re: LuaGameScript.small_tick
If something like this is done, I think it should be the other way round. If the new property contains the upper, i.e. slower changing bits, everything simply using LuaGameScript.tick will continue to work without issue until tick 2^52-1, instead of breaking immediately.
However, I question the necessity of accessing the upper 12 bits - as stated in the FFF, 52 bits last for 2.37 million years. Even with increased game speed, the limit won't be less than thousands of years of continuously running the same (!) save. It seems unlikely that this is a problem anybody will actually encounter.
However, I question the necessity of accessing the upper 12 bits - as stated in the FFF, 52 bits last for 2.37 million years. Even with increased game speed, the limit won't be less than thousands of years of continuously running the same (!) save. It seems unlikely that this is a problem anybody will actually encounter.
Re: LuaGameScript.small_tick
I do not get what this request is about. In all realistic cases i assume the upper 12 bits will always be 0 so every tick value can be represented accurately by a `double` and as such LuaGameScript::tick exposing full value is the best possible solution.
Re: LuaGameScript.small_tick
It's more likely that by the time anyone would be capable of reaching 2^52 Factorio will be updated to a newer Lua version and thus be capable of operating on 64-bit integers.DaveMcW wrote: ↑Sun Dec 17, 2023 4:44 am FFF 388 announced engine support for ticks up to 2^64, but only Lua support for ticks up to 2^52.
We can work around the Lua limit by breaking up the tick into two 32-bit numbers. The upper 32 bits are easy to calculate from LuaGameScript.tick. But we need a new property that contains the lower 32 bits. Call it LuaGameScript.small_tick.
-
- Smart Inserter
- Posts: 2768
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: LuaGameScript.small_tick
Agreed with the other comments here that this is probably not necessary. I mean, just to get the tick count to run out in your lifetime, you'd need to run the game at speed 40 to 50 thousand, maybe faster, depending on your current age and how long you'll live to. Even at 10k speed, it's apt to not run out until several generations down the line. Putting aside whether or not any modern (non-mainframe server) computers can even run the game at those speeds, it would be pointless as we wouldn't be able to process what's going on.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: LuaGameScript.small_tick
It's this simple: 2^52 ticks is over two million years.
Re: LuaGameScript.small_tick
And even 2^52 microseconds (that is, a million UPS) is well over a hundred years.