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
Burner Inserter
Burner Inserter
Posts: 15
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: 1725
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: 19
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.
Post Reply

Return to “Modding interface requests”