Getting event filter results
Posted: Sun Oct 05, 2025 2:59 pm
I'm starting to build an event with lots filter case
To summarise to look like this:
Some filter are easy to reproduce in the event function, others are not
I would suggest that the event parameter contain a field that give filter results,
it would be a 1-1 map of filters with 2 possible values: true, false
if factorio does minimal evaluation for filters, it can have a nil value if the filter has not been evaluated
here it could give a result like
which mean it's a train stop
This mean that really big events could use the results of the filters to route to smaller events without reevaluating every filters manually
To summarise to look like this:
Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
game.print(serpent.block(event))
end, {
{filter="type", type="constant-combinator"},
{filter="ghost_type", ghost_type="constant-combinator"},
{filter="type", type="train-stop"},
{filter="ghost_type", ghost_type="train-stop"},
{filter="rail"},
{filter="rail-signal"}
})I would suggest that the event parameter contain a field that give filter results,
it would be a 1-1 map of filters with 2 possible values: true, false
if factorio does minimal evaluation for filters, it can have a nil value if the filter has not been evaluated
here it could give a result like
Code: Select all
{
consumed_items = "[LuaInventory: temp]",
entity = "[LuaEntity: train-stop at [gps=157.0,1.0]]",
name = 6,
player_index = 1,
tick = 214527,
filter_result={
false,
false,
true,
nil,
nil,
nil,
}
}
This mean that really big events could use the results of the filters to route to smaller events without reevaluating every filters manually