Skip to content

Instantly share code, notes, and snippets.

@morsk
Last active February 17, 2025 12:33
Show Gist options
  • Save morsk/9d812d8ad3301b70e91e46d890cdde88 to your computer and use it in GitHub Desktop.
Save morsk/9d812d8ad3301b70e91e46d890cdde88 to your computer and use it in GitHub Desktop.
Find entities using the named logistic group
/sc --[[ logi group finder ]]
local c = 0
local function check_for_group(e, section_container, group_name)
for _, section in pairs(section_container.sections) do
if section.group == group_name then
game.player.print({"", e.localised_name, ": ", e.gps_tag})
c = c + 1
end
end
end
local function find(group_name)
for _, s in pairs(game.surfaces) do
for _, e in pairs(s.find_entities_filtered{type={"constant-combinator", "space-platform-hub", "roboport", "character"}}) do
if e.get_logistic_sections() then
check_for_group(e, e.get_logistic_sections(), group_name)
elseif e.get_control_behavior() then
check_for_group(e, e.get_control_behavior(), group_name)
end
end
end
game.print("Found " .. c .. " entities.")
end
--[[ parameterization is on the last line because it's easiest to change on the command line ]]
find "roboport - nauvis"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment