I have a prototype definition for an entity that contains a collision mask. The collision mask has an empty "layers" definition:
Note that the prototype does define layers as empty (it can not be omitted; more about that in a second).
Now when I create an entity using LuaSurface::create_entity, this is what I receive:
The prototype for this entity does NOT contain the layer information. I want to use collision_mask_util.masks_collide from the lualib to check whether any of these entities collides with others and that crashes my mod because the function assumes that any collision mask *does* contain a "layers" attribute.
Either any entity created by the game should contain the layers attribute even if it is empty (do not omit when there is no layer defined) *OR* the lualib needs to be tolerant of the layers attribute missing. The current state seems to be a bug.
[boskid][2.0.23] Entity prototypes are missing "layers" information, leading to collision_mask_util.masks_collide crash
Re: [boskid][2.0.23] Entity prototypes are missing "layers" information, leading to collision_mask_util.masks_collide cr
Thanks for the report. Issue is now fixed for 2.0.24. My intention was to have "layers" be mandatory in all cases using the "make modders happy by reducing amount of formats data can be given" and this code was also structured in a way that was supposed to guarantee layers is given, however there is an intermediate step here when giving collision mask: it is first saved as one of the internal types, a PropertyTree where a "layers" was constructed however because it was not given any items it was considered as "unknown type" and as such it was not causing table to be pushed. I forced the type of this inner variable to explicitly say it is a table even if there are no items inside of it which fixes the issue.