Add APIs to manage logistic groups

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Sharparam
Inserter
Inserter
Posts: 28
Joined: Sat Mar 25, 2023 11:21 pm
Contact:

Add APIs to manage logistic groups

Post by Sharparam »

There doesn't seem to be any APIs to manipulate logistic groups for mods. This makes it impossible to implement custom combinator UIs where the user needs to be able to select and manage logistic groups, just like with base game combinators.

We need APIs to:
  • Get all existing logistic groups (with the count of how many things are using the group)
  • Create logistic groups (maybe not necessary as an API as just setting the "group" property on a section will implicitly create it)
  • Delete a logistic group
Context:
Image

This is the base game "Change logistic group" dialog which shows the existing groups and allows the player to select or delete them.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1743
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Add APIs to manage logistic groups

Post by Pi-C »

Sharparam wrote: Wed Nov 06, 2024 8:33 pm We need APIs to:
  • Get all existing logistic groups (with the count of how many things are using the group)
  • Create logistic groups (maybe not necessary as an API as just setting the "group" property on a section will implicitly create it)
  • Delete a logistic group
I'm strongly in support of this, but I'd like to add one feature to the list: the ability to hide a group from the list visible to players.
Use case

Autodrive already gave vehicles based on car prototypes logistic behavior before Factorio 2.0. In the latest versions, players could also prioritize items for supplying the vehicle itself (auto-reloading weapons, auto-refueling, and auto-repairing) – and set logistic requests for first-choice items. I'm now updating my mod to Factorio 2.0, and I'd like to use the in-built logistic system for those vehicles that support it.

Basically, I add a uniquely named logistic section (containing vehicle.unit_number) to each vehicle controlled by my mod that has requests for ammo/fuel/repair-tools. This logistic section is updated whenever the player changes requests. Players are not supposed to reuse these logistic sections because the requests in those sections may be reset by my mod at any time. Moreover, when there are a bunch of vehicles controlled by Autodrive, the list of logistic groups will be spammed with names of groups that players should not use.

A flag LuaLogisticSection::hidden would be very convenient!
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
kelianmao
Burner Inserter
Burner Inserter
Posts: 18
Joined: Thu Jan 14, 2021 5:52 pm
Contact:

Re: Add APIs to manage logistic groups

Post by kelianmao »

+1

Further requests:
1. Get a group by name. I guess if the get all existing groups api returns a LuaCustomTable, you could do it by indexing that table. Currently you can create a section, set its group to the name, and modify it. But this must be done inside a logistic entity.
2. Add an event for the renaming of a logistic group. I want to enforce the structure of certain groups, and I can enforce the slots by monitoring on on_entity_logistic_slot_changed and undoing the change, but there is no way to do that if someone simply renames the section.
Progor
Manual Inserter
Manual Inserter
Posts: 1
Joined: Wed Nov 20, 2024 2:38 am
Contact:

Re: Add APIs to manage logistic groups

Post by Progor »

+1

I am also building something based on Logistic Sections - a MicroController spin-off that uses Logistic Sections as its memory cells, with hidden internal constant combinators (one for disconnected internal memory, one for red output, and one for green output). Each logistic section becomes a "memory bank" that can be addressed by index or group name. The memory bank can be used as a Vector or you can index individual slots by index, signal type, or sorted value indexing.

I can work around it by showing the underlying constant combinator gui when they need to edit sections, then showing the microcontroller gui again when they close it, but that's a bit clunky. It would be nice if it were more integrated, but the only thing I am missing to make that work is the ability to list existing logistic section groups.
User avatar
Sharparam
Inserter
Inserter
Posts: 28
Joined: Sat Mar 25, 2023 11:21 pm
Contact:

Re: Add APIs to manage logistic groups

Post by Sharparam »

Bumping this since it's been several months without a response. Got another bug report from a user confused about not being able to see their logistic groups in the edit window, understandably.
Krydax
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Jul 09, 2021 6:18 pm
Contact:

Re: Add APIs to manage logistic groups

Post by Krydax »

+1 from me as well. Seems really odd that modded UIs cannot access logistic groups properly!
ahicks
Inserter
Inserter
Posts: 27
Joined: Sat Jul 13, 2024 10:45 pm
Contact:

Re: Add APIs to manage logistic groups

Post by ahicks »

The Factorio Access use case for this is probably pretty obvious--we need to be able to present a list of groups to the player without going through game GUI at all. Our "workaround" whenever we get that far was going to be figure out if we can edit them by finding all existing sections and modifying a section linked to the group, then make this exact API request for a longer term solution which won't require iterating everything on all surfaces.

It would be nice to have the same thing for trains as well--at least a list. Same reason: scanning all entities is not great. I have been told by the sighted co-devs that in the case of trains groups only exist as long as a train is using them, but assuming that understanding is incorrect we'd need this for the even more obvious reason of scanning the surfaces not being enough. I thougfht there was an API request for that already, perhaps actually by me, but if not I'll definitely be putting one in eventually.
Post Reply

Return to “Modding interface requests”