LuaEntity.last_user can be nil on a LuaEntity returned from the game, but that field does not accept nil assign

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 583
Joined: Tue May 19, 2015 1:56 am
Contact:

LuaEntity.last_user can be nil on a LuaEntity returned from the game, but that field does not accept nil assign

Post by Reika »

That is, trying to assign <LuaEntity>.last_user = nil throws an error, but LuaEntities returned via the scripting engine - such as find_entities_filtered - can have a nil value for that field.

This is bad on two fronts:

The first is that this makes no sense; if the game can give LuaEntities with nil value for last_user, that must be an acceptable value (ie causes no issues) for that parameter, and thus it makes no sense to forbid a nil assign.

The second problem is more practical: it means you cannot "clone" an entity directly; the entity that exists may not be allowed to be recreated with that exact data. Just copying all the entity data from one to another runs the risk of throwing an error, simply because one of the fields contains a value which is not permissible to assign to that same field.

Hell, you can throw an error by assigning an entity its own parameters: entity.last_user = entity.last_user will throw an error if the entity has a nil user, as some script-returned entities do.
Image

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

Re: LuaEntity.last_user can be nil on a LuaEntity returned from the game, but that field does not accept nil assign

Post by Rseding91 »

Thanks for the report. It's now fixed for the next version of 0.17.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 583
Joined: Tue May 19, 2015 1:56 am
Contact:

Re: LuaEntity.last_user can be nil on a LuaEntity returned from the game, but that field does not accept nil assign

Post by Reika »

Rseding91 wrote:
Fri Oct 04, 2019 3:19 am
Thanks for the report. It's now fixed for the next version of 0.17.
As in nil is now a valid assign?
Image

Bilka
Factorio Staff
Factorio Staff
Posts: 3299
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaEntity.last_user can be nil on a LuaEntity returned from the game, but that field does not accept nil assign

Post by Bilka »

Reika wrote:
Fri Oct 04, 2019 6:28 am
Rseding91 wrote:
Fri Oct 04, 2019 3:19 am
Thanks for the report. It's now fixed for the next version of 0.17.
As in nil is now a valid assign?
Yes.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Resolved Problems and Bugs”