Page 1 of 1

API Doc: LuaTilePrototype.collision_mask is dictionary

Posted: Tue Oct 18, 2016 6:19 pm
by Mooncat
Bug:
The document says LuaTilePrototype.collision_mask is an array of string, but in fact it is dictionary string → boolean, same as LuaItemPrototype.flags.

I used serpent.dump to find that, after getting stuck for a few minutes on checking whether the tile is walkable. :)

Re: API Doc: LuaTilePrototype.collision_mask is dictionary

Posted: Tue Oct 18, 2016 6:23 pm
by aubergine18
Is there a list of possible keys for that dictionary anywhere? I was trying to find list of available options last night but other than scraping data.raw I didn't get very far.

Re: API Doc: LuaTilePrototype.collision_mask is dictionary

Posted: Tue Oct 18, 2016 6:25 pm
by kovarex
That is probably boost property tree construction limitation. It accepts array of strings without values, but the export contains the values. This will be changed in the future versions (0.15 probably) once we start using our own property tree implementation.

Re: API Doc: LuaTilePrototype.collision_mask is dictionary

Posted: Tue Oct 18, 2016 6:26 pm
by Rseding91
Fixed for 0.14.15.

Re: API Doc: LuaTilePrototype.collision_mask is dictionary

Posted: Tue Oct 18, 2016 6:27 pm
by Rseding91
kovarex wrote:That is probably boost property tree construction limitation. It accepts array of strings without values, but the export contains the values. This will be changed in the future versions (0.15 probably) once we start using our own property tree implementation.
It's intentional. It allows you to quickly check if the collision mask has a value in the Lua state by simply checking if the key exists in the dictionary. If it was exported as the prototype definition does it: you would have to iterate over the entire list to check if 1 value existed.

Re: API Doc: LuaTilePrototype.collision_mask is dictionary

Posted: Tue Oct 18, 2016 7:01 pm
by Mooncat
aubergine18 wrote:Is there a list of possible keys for that dictionary anywhere? I was trying to find list of available options last night but other than scraping data.raw I didn't get very far.
I checked tiles.lua for the keys. Maybe this is still accurate: https://wiki.factorio.com/index.php?tit ... lisionMask. I don't see any sign of having any new collision mask since 2015. :lol:
Rseding91 wrote:
kovarex wrote:That is probably boost property tree construction limitation. It accepts array of strings without values, but the export contains the values. This will be changed in the future versions (0.15 probably) once we start using our own property tree implementation.
It's intentional. It allows you to quickly check if the collision mask has a value in the Lua state by simply checking if the key exists in the dictionary. If it was exported as the prototype definition does it: you would have to iterate over the entire list to check if 1 value existed.
Yes, I vote for dictionary too. Thanks! :D