LuaGameScript.small_tick

Things that we aren't going to implement
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3719
Joined: Tue May 13, 2014 11:06 am
Contact:

LuaGameScript.small_tick

Post by DaveMcW »

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.
Freddy404
Burner Inserter
Burner Inserter
Posts: 18
Joined: Fri Nov 10, 2023 3:54 pm
Contact:

Re: LuaGameScript.small_tick

Post by Freddy404 »

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.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3078
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: LuaGameScript.small_tick

Post by boskid »

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.
curiosity
Filter Inserter
Filter Inserter
Posts: 482
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: LuaGameScript.small_tick

Post by curiosity »

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.
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.
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: LuaGameScript.small_tick

Post by FuryoftheStars »

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
quyxkh
Smart Inserter
Smart Inserter
Posts: 1031
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: LuaGameScript.small_tick

Post by quyxkh »

It's this simple: 2^52 ticks is over two million years.
pleegwat
Filter Inserter
Filter Inserter
Posts: 278
Joined: Fri May 19, 2017 7:31 pm
Contact:

Re: LuaGameScript.small_tick

Post by pleegwat »

And even 2^52 microseconds (that is, a million UPS) is well over a hundred years.
Post Reply

Return to “Won't implement”