add filter to find_entities_filtered to find only entities with to_be_upgraded = true

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

add filter to find_entities_filtered to find only entities with to_be_upgraded = true

Post by Optera »

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:

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
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.
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.
Post Reply

Return to “Implemented mod requests”