Page 1 of 1

[2.0.57] LuaForce::get_logistic_group() not populating "members"

Posted: Thu Jun 19, 2025 9:03 pm
by Sharparam
Testing out the new logistic group APIs added in 2.0.56, but testing on 2.0.57. Many thanks for adding this since it means being able to finally flesh out the remaining bits of my mod!

There seems to be an issue with the "members" field on the `LogisticGroup` table returned from `LuaForce::get_logistic_group()` though. It is empty despite my test map having ~2.4k combinators that all have a section using a group called "test group". (`#` operator returns 0 and iterating over it with `pairs()` gets no results.)

Snippet of the code I use to work with the new APIs:

Code: Select all

local player = game.get_player(player_index)
local force = player.force

local api_groups = force.get_logistic_groups()

for _, api_group_name in pairs(api_groups) do
  local api_group = force.get_logistic_group(api_group_name)
  -- local count = 0
  -- for _, section in pairs(api_group.members) do
  --   log:debug("member ", count, "( ", section.index, ")")
  --   count = count + 1
  -- end
  local count = #api_group.members
  table.insert(result, { name = api_group_name, count = count })
end
`count` ends up being 0 while the base game UI shows the expected ~2.4k.

(With the commented bit I tested with just in case it was an issue with using `#` to get the size of it.)

For more context, I posted about it on Discord and Bilka clarified the "members" field should be the sections and them not being there is likely a bug.

Re: [2.0.57] LuaForce::get_logistic_group() not populating "members"

Posted: Thu Jun 19, 2025 9:10 pm
by Bilka
Not sure what sections should or shouldn't be, to be clear, I think my message was wrong, hence pointing to post here.

Re: [2.0.57] LuaForce::get_logistic_group() not populating "members"

Posted: Thu Jun 19, 2025 9:25 pm
by boskid
Do you have a reproduction steps? A save file i could take a look + a mod or a console command?

When testing manually, everything seems to be working fine. Using console command:

Code: Select all

/c
local player = game.player
local force = player.force

local api_groups = force.get_logistic_groups()
local result = {}
for _, api_group_name in pairs(api_groups) do
  local api_group = force.get_logistic_group(api_group_name)
  local count = #api_group.members
  table.insert(result, { name = api_group_name, count = count })
end

game.print(serpent.line(result))
i get a valid result:
06-19-2025, 23-24-38.png
06-19-2025, 23-24-38.png (86.2 KiB) Viewed 752 times

Re: [2.0.57] LuaForce::get_logistic_group() not populating "members"

Posted: Thu Jun 19, 2025 9:42 pm
by Sharparam
In your example you're using requester chests, this does work when I test it as well.

I tested now with a section containing one filter, used in a requester chest and in a constant combinator.

In both the combinator and requester chest's "Change logistic group" dialog, it shows a count of 2 (being used in the requester chest and constant combinator).

However, in my code using the `members` field on `LogisticGroup`, I get 1 (the requester chest, `members[1].owner.name == "requester-chest"`).

Edit: I've attached a save file for the above test with the requester chest and constant combinator, as well as with my custom modded combinator. This save file uses the unreleased update of my mod on the `feature/logistic-group-apis` branch, I've attached a zip for that as well. But loading the map and just removing the custom entities and using your console command test from before should exhibit the same result.

Edit 2: Buffer chests also work with the API. Adding a buffer chest to the above scenario, the base game gives a count of 3 while the Lua API gives 2.

Re: [2.0.57] LuaForce::get_logistic_group() not populating "members"

Posted: Thu Jun 19, 2025 10:11 pm
by boskid
Fixed for 2.0.58.