[1.1.60] LuaGameScript::get_filtered_entity_prototypes
Posted: Tue Jun 21, 2022 6:10 am
Same issue as 102706, only with LuaGameScript::get_filtered_entity_prototypes. Entity prototypes with the collision_mask flag "colliding-with-tiles-only" are not found on a filtered search where collision_mask is one of the filter parameters.
I don't know if the fix to 102706 will fix this too or not, thus I'm reporting it.
code excerpt from data.lua (creation of entity prototype):
code excerpt from control.lua (attempt to find entity prototype via get_filtered_entity_prototypes):
log output:
I don't know if the fix to 102706 will fix this too or not, thus I'm reporting it.
code excerpt from data.lua (creation of entity prototype):
Code: Select all
local artificial_tile_collision_layer = collision_mask_util.get_first_unused_layer() --> passed to control stage via dummy item and tech holding the returned name and then stored to global.layer during on_init
[...]
local tree_roots = { --> added to table with other prototypes that is then later fed into data:extend()
type = "simple-entity",
name = "tree-roots",
icon = "__core__/graphics/icons/unknown.png",
icon_size = 64,
flags = {"placeable-neutral", "placeable-off-grid", "hidden"},
collision_box = {{-0.95, -0.95}, {0.95, 0.95}},
collision_mask = {"colliding-with-tiles-only", artificial_tile_collision_layer},
picture = {
layers = {
{
filename = "__core__/graphics/empty.png",
size = 1
}
}
}
}
Code: Select all
log("Collision mask: " .. global.layer)
log("Search by collision_mask only...")
local prototypes = game.get_filtered_entity_prototypes{{filter = "collision-mask", mask = global.layer, mask_mode = "collides"}}
if prototypes["tree-roots"] then log("tree-roots found; collision mask: " .. serpent.line(prototypes["tree-roots"].collision_mask_with_flags)) else log("no tree roots") end
log("Search by name and collision_mask...")
local tree_roots = game.get_filtered_entity_prototypes{{filter = "name", name = "tree-roots"}, {filter = "collision-mask", mask = global.layer, mask_mode = "collides", mode = "and"}}
if tree_roots["tree-roots"] then log("tree-roots found; collision mask: " .. serpent.line(tree_roots["tree-roots"].collision_mask_with_flags)) else log("no tree roots") end
log("Search by name only...")
local tree_roots2 = game.get_filtered_entity_prototypes{{filter = "name", name = "tree-roots"}}
if tree_roots2["tree-roots"] then log("tree-roots found; collision mask: " .. serpent.line(tree_roots2["tree-roots"].collision_mask_with_flags)) else log("no tree roots") end
Code: Select all
1317.840 Script @__RestrictionsOnArtificialTiles__/control.lua:263: Collision mask: layer-13
1317.840 Script @__RestrictionsOnArtificialTiles__/control.lua:265: Search by collision_mask only...
1317.840 Script @__RestrictionsOnArtificialTiles__/control.lua:267: no tree roots
1317.840 Script @__RestrictionsOnArtificialTiles__/control.lua:269: Search by name and collision_mask...
1317.840 Script @__RestrictionsOnArtificialTiles__/control.lua:271: no tree roots
1317.840 Script @__RestrictionsOnArtificialTiles__/control.lua:273: Search by name only...
1317.840 Script @__RestrictionsOnArtificialTiles__/control.lua:275: tree-roots found; collision mask: {["colliding-with-tiles-only"] = true, ["layer-13"] = true}