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

This subforum contains all the issues which we already resolved.
User avatar
Sharparam
Inserter
Inserter
Posts: 34
Joined: Sat Mar 25, 2023 11:21 pm
Contact:

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

Post 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.
Attachments
factorio-current.log
Log from starting game to triggering the dialog that runs the code trying to count "members"
(11.56 KiB) Downloaded 16 times
Last edited by Sharparam on Thu Jun 19, 2025 9:10 pm, edited 1 time in total.
Bilka
Factorio Staff
Factorio Staff
Posts: 3410
Joined: Sat Aug 13, 2016 9:20 am
Contact:

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

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4013
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

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

Post 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 591 times
User avatar
Sharparam
Inserter
Inserter
Posts: 34
Joined: Sat Mar 25, 2023 11:21 pm
Contact:

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

Post 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.
Attachments
cybersyn-combinator_2.7.3.zip
(178.91 KiB) Downloaded 25 times
requester_and_combi.zip
(180.03 KiB) Downloaded 18 times
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4013
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

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

Post by boskid »

Fixed for 2.0.58.
Post Reply

Return to “Resolved Problems and Bugs”