[0.14] LuaEntityPrototype.collision_mask wrong definition

Bugs that are actually features.
Neemys
Filter Inserter
Filter Inserter
Posts: 461
Joined: Sat Apr 09, 2016 6:16 pm
Contact:

[0.14] LuaEntityPrototype.collision_mask wrong definition

Post by Neemys »

According to the Lua Api for LuaEntityPrototype.collision_mask It should return an array of string.

Placing a rail (or any other entity that have a collision_mask) on the ground, put the mouse over it and run the following command :

Code: Select all

/c game.player.print(serpent.block(game.player.selected.prototype.collision_mask))
Expected result : It should print an array of string

Code: Select all

 
{"floor-layer","object-layer","water-tile"}
Instead it print a table of string->boolean

Code: Select all

{["floor-layer"]=true,["object-layer"]=true,["water-tile"]=true}
Want more space restriction ? Or maybe you want to be forced to use train for other thing than ore and oil ? Try Building Platform Mod !
Rseding91
Factorio Staff
Factorio Staff
Posts: 15913
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.14] LuaEntityPrototype.collision_mask wrong definition

Post by Rseding91 »

It's not possible to print:

Code: Select all

{"floor-layer","object-layer","water-tile"}
That's actually:

Code: Select all

{[1]="floor-layer",[2]="object-layer",[3]="water-tile"}
Which, I can change it to that, but the reason I left it as name <> bool mapping is so you can index it to check if any value is in the list without needing to iterate the collection.
If you want to get ahold of me I'm almost always on Discord.
Neemys
Filter Inserter
Filter Inserter
Posts: 461
Joined: Sat Apr 09, 2016 6:16 pm
Contact:

Re: [0.14] LuaEntityPrototype.collision_mask wrong definition

Post by Neemys »

The printing was just to demonstrate that it wasn't really an array of string. I use it in script and was searching why things were not working when I use value to check for a mask to be present.

I'm not really asking to change the real definition of the collision_mask, I think just changing the API doc that it state that it is string->boolean should be enough to avoid confusion.
Want more space restriction ? Or maybe you want to be forced to use train for other thing than ore and oil ? Try Building Platform Mod !
Post Reply

Return to “Not a bug”