[0.15.16] luadoc for LuaEntity.unit_number

Place to get help with not working mods / modding interface.
Post Reply
folk
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Fri Mar 03, 2017 5:00 pm
Contact:

[0.15.16] luadoc for LuaEntity.unit_number

Post by folk »

Hi,

So the luadocs for http://lua-api.factorio.com/latest/LuaE ... nit_number is a bit unclear;
Are unit_numbers universally unique for the lifetime of a whole game?

That is to say, if one was destroyed, is there ever any chance that another LuaEntity will have the unit_number of the destroyed one?

Thank you!

posila
Factorio Staff
Factorio Staff
Posts: 5202
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.15.16] luadoc for LuaEntity.unit_number

Post by posila »

folk wrote:Are unit_numbers universally unique for the lifetime of a whole game?
Yes ... even though it might oveflow (it is uint32) which would potentially cause two or more entities to have same unit number, but I have never seen it even come close to overflowing.

folk
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Fri Mar 03, 2017 5:00 pm
Contact:

Re: [0.15.16] luadoc for LuaEntity.unit_number

Post by folk »

That's what I assumed :-)
Thank you!

Oh, I see the thread was moved to "modding help". I opened it as a bug report specifically because I wanted the luadocs clarified in the name of posterity, future reference, and the good of mankind. I already assumed it behaved like you described it, but of course it's good to get it confirmed.

posila
Factorio Staff
Factorio Staff
Posts: 5202
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.15.16] luadoc for LuaEntity.unit_number

Post by posila »

I changed the doc as I moved the thread, but I felt like it is more appropriate to move the thread to Modding help rather than to resolved issues :)

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: [0.15.16] luadoc for LuaEntity.unit_number

Post by Choumiko »

posila wrote:Yes ... even though it might oveflow (it is uint32) which would potentially cause two or more entities to have same unit number, but I have never seen it even come close to overflowing.
Challenge accepted! Anyone? :D

I guess the same is true for LuaTrain:id

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15.16] luadoc for LuaEntity.unit_number

Post by Rseding91 »

Choumiko wrote:
posila wrote:Yes ... even though it might oveflow (it is uint32) which would potentially cause two or more entities to have same unit number, but I have never seen it even come close to overflowing.
Challenge accepted! Anyone? :D

I guess the same is true for LuaTrain:id
Same for map tick as well :P

If you ever manage to overflow it in a normal game that isn't purpose-created to do so then I'll give you a free steam key because I don't think anyone will ever do it :P
If you want to get ahold of me I'm almost always on Discord.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.15.16] luadoc for LuaEntity.unit_number

Post by bobingabout »

that's like, 2.3 years of game time before a tick overflow.
4 billion units is something that is far more obtainable. all you really need to do is set up a few biter farms, and eventually it will overflow.

what happens when it does overflow?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15.16] luadoc for LuaEntity.unit_number

Post by Rseding91 »

bobingabout wrote:that's like, 2.3 years of game time before a tick overflow.
4 billion units is something that is far more obtainable. all you really need to do is set up a few biter farms, and eventually it will overflow.

what happens when it does overflow?
You'd have to kill > 1 per tick since the creation of the map for a total of 60 per second or 3600 biters per minute.
If you want to get ahold of me I'm almost always on Discord.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.15.16] luadoc for LuaEntity.unit_number

Post by bobingabout »

Rseding91 wrote:
bobingabout wrote:that's like, 2.3 years of game time before a tick overflow.
4 billion units is something that is far more obtainable. all you really need to do is set up a few biter farms, and eventually it will overflow.

what happens when it does overflow?
You'd have to kill > 1 per tick since the creation of the map for a total of 60 per second or 3600 biters per minute.
when I said 2.3 years, that's for the tick counter to overflow.

And yes, when you consider a map is infinite, if your goal is not to clear out nests, you can quite easily run a train line, protected by laser turrets, and have a result where biters are attacking constantly. do this in enough places and you can drastically reduce the amount of time before the unit counter over flows.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15.16] luadoc for LuaEntity.unit_number

Post by Rseding91 »

bobingabout wrote:
Rseding91 wrote:
bobingabout wrote:that's like, 2.3 years of game time before a tick overflow.
4 billion units is something that is far more obtainable. all you really need to do is set up a few biter farms, and eventually it will overflow.

what happens when it does overflow?
You'd have to kill > 1 per tick since the creation of the map for a total of 60 per second or 3600 biters per minute.
when I said 2.3 years, that's for the tick counter to overflow.

And yes, when you consider a map is infinite, if your goal is not to clear out nests, you can quite easily run a train line, protected by laser turrets, and have a result where biters are attacking constantly. do this in enough places and you can drastically reduce the amount of time before the unit counter over flows.
You don't seem to understand :) The map tick and unit number are both unsigned 32 bit numbers. The map tick advances at 1 per tick (obviously). The unit number only increments when a new entity using unit numbers is created. In order to cause a biter to be created you have to kill a biter which means in order to make the unit number advance faster than the map tick you would need to kill > 1 biter per game tick.
If you want to get ahold of me I'm almost always on Discord.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.15.16] luadoc for LuaEntity.unit_number

Post by bobingabout »

ya, I get that. a good biter farm can easily be killing 10 biters a second.

if you find a large cluster of nests, and place laser turrets just outside the firing range to hit the nests, you'll have a steady stream of biters coming to attack the turrets and die.

I'll admit, the need to actually do this on purpose isn't really needed in the current game, but in a situation where the biters drop something you need, EG added by a mod, then this setup can become pretty standard.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Post Reply

Return to “Modding help”