Skip to content

Commit

Permalink
Scanner: pull out pipe ends to their own subcategory
Browse files Browse the repository at this point in the history
  • Loading branch information
ahicks92 committed Oct 20, 2024
1 parent e674d90 commit ef454d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions scripts/scanner/backends/single-entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
We have to declare categorization and subcategorization functions for everything
by declaring our backends. Simple already does everything else for us.
]]
local BuildingTools = require("scripts.building-tools")
local decl = require("scripts.scanner.backends.simple").declare_simple_backend
local functionize = require("scripts.functools").functionize
local Info = require("scripts.fa-info")
Expand Down Expand Up @@ -191,4 +192,16 @@ mod.Roboport = decl("fa.scanner.backends.Roboport", {
return cat2(ent.name, ent.backer_name)
end,
})

mod.Pipe = decl("fa.scanner.backends.Pipe", {
category_callback = functionize(SC.CATEGORIES.LOGISTICS),

---@param ent LuaEntity
subcategory_callback = function(ent)
local fluids = ent.get_fluid_contents()
local fluid = next(fluids) or "<NONE>"
local end_part = BuildingTools.is_a_pipe_end(ent) and "<END>" or "<NONE>"
return string.format("%s/%s/%s", ent.name, fluid, end_part)
end,
})
return mod
4 changes: 2 additions & 2 deletions scripts/scanner/surface-scanner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ local BACKEND_LUT = {
["mining-drill"] = SEB.MiningDrill,
["offshore-pump"] = SEB.Production,
["pipe-to-ground"] = SEB.LogisticsWithFluid,
["pipe"] = SEB.LogisticsWithFluid,
["pipe"] = SEB.Pipe,
["player-port"] = SEB.Other,
["power-switch"] = SEB.Logistics,
["programmable-speaker"] = SEB.Logistics,
Expand Down Expand Up @@ -200,7 +200,7 @@ end
local surface_state = GlobalManager.declare_global_module(
"scanner",
new_empty_surface,
{ root_field = "surfaces", ephemeral_state_version = 4 }
{ root_field = "surfaces", ephemeral_state_version = 5 }
)

-- Given a backend setup and an array of entities, dispatch the entities to the
Expand Down

0 comments on commit ef454d0

Please sign in to comment.