Last active
February 17, 2025 12:33
-
-
Save morsk/9d812d8ad3301b70e91e46d890cdde88 to your computer and use it in GitHub Desktop.
Find entities using the named logistic group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/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