Page 1 of 1

[0.14] LuaEntityPrototype.collision_mask wrong definition

Posted: Sun Oct 16, 2016 12:48 am
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}

Re: [0.14] LuaEntityPrototype.collision_mask wrong definition

Posted: Sun Oct 16, 2016 1:25 am
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.

Re: [0.14] LuaEntityPrototype.collision_mask wrong definition

Posted: Sun Oct 16, 2016 1:46 am
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.