add filter to find_entities_filtered to find only entities with to_be_upgraded = true
Posted: Sun Sep 01, 2019 6:59 am
I'd like to have a way to find only entities marked for upgrades.
Currently to find these entities we have to find all entities then iterate them to filter the ones marked for upgrades:
According to Rseding expanding find_entities_filtered to check to_be_upgraded would be faster than type filtering and certainly a lot quicker than lua post filtering.
Currently to find these entities we have to find all entities then iterate them to filter the ones marked for upgrades:
Code: Select all
local entities = LuaLogisticsCell.owner.surface.find_entities{area=bounds, force=logsiticNetwork.force}
for _, e in pairs(entities) do
if e.to_be_upgraded() then
...
end
end
Rseding91 wrote:type filtering is dereferencing the entity pointer and calling a virtual function on it to get the type.
reading to_be_upgraded would be faster since it's a non-virtual function that just reads a bit mask.