How to make an inventory that incudes the exact contents (slot by slot) in blueprints?

Place to get help with not working mods / modding interface.
Post Reply
mrvn
Smart Inserter
Smart Inserter
Posts: 5710
Joined: Mon Sep 05, 2016 9:10 am
Contact:

How to make an inventory that incudes the exact contents (slot by slot) in blueprints?

Post by mrvn »

I'm working on a crafting combinator and currently am stuck at support for modules.

Currently the crafting combiantor has a chest containing modules in a user defined order, one module per slot. When setting a recipe the combinator simply tries to insert modules in the order they are in the chest. When removing a recipe the modules are put back into the chest in the order they are in the assembler into any free slots. Overall this means the order of the modules in the chest remains the same.

This allows the user to place productivity modules first in the chest and the crafting combinator will use them whenever possible. When not it will keep going and use any efficiency or speed modules later in the chest.


Now here comes the problem:

When I make a blueprint of the assembler and crafting combinator then the assembler gets an item-request-proxy for the inserted modules. For the chest I have to add my own item-request-proxy. That gets me the right number of modules but in a random order.

How do I go about preserving the order the modules should be in.

PS: one untried idea I have is to use a cargo wagon instead of a chest and set item filters to lock in the order of modules. I want one module per slot so I only need the order, not any count per slot.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1654
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: How to make an inventory that incudes the exact contents (slot by slot) in blueprints?

Post by Pi-C »

Did you already consider script inventories? They can be resized if necessary, and you can loop over the slots just like it was a common inventory, so it is possible to preserve order.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

mrvn
Smart Inserter
Smart Inserter
Posts: 5710
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: How to make an inventory that incudes the exact contents (slot by slot) in blueprints?

Post by mrvn »

Pi-C wrote:
Fri Apr 19, 2024 4:46 am
Did you already consider script inventories? They can be resized if necessary, and you can loop over the slots just like it was a common inventory, so it is possible to preserve order.
How would the user interact with that inventory?
How would the blueprint include the contents of that inventory?
How would bots place modules into that inventory after blueprinting?

Creating an inventory is not the problem. The chest entity already has one. It's the contents that's the problem in blueprints.

Post Reply

Return to “Modding help”