Page 1 of 1

Restrict item storage and transportation

Posted: Sat Feb 18, 2023 4:14 pm
by SWeini
Currently every item can be
- in player inventory
- in container inventory
- moved by belt
- moved by inserter
- moved by bot
- placed on ground

I'd like to restrict some items from specific kinds of storage/transportation. Probably items on ground shouldn't be restricted because spilling items on the ground is the last way out to place items that have nowhere else to go.

1) This could allow mod authors to make different challenges for different recipe chains. Most overhaul mods suffer from complex recipe chains but most players have their default approach like cityblocks or mainbus that works for everything. This can get boring.

2) This could allow mod authors to make the game more realistic. For example they could prevent trains or large buildings on belts.

Re: Restrict item storage and transportation

Posted: Sat Feb 18, 2023 8:35 pm
by FuryoftheStars
Yeah, I would probably say placed on ground shouldn't have a restriction, but I definitely have had to desire to prevent storing some things in chests... like locomotives by the hundreds....

I don't know what the dev's opinion would be on this, though. I know they veto'd allowing regular chests to have filters due to performance, so it's hard to say if this would still rub that or not.

Re: Restrict item storage and transportation

Posted: Sat Feb 18, 2023 9:21 pm
by SWeini
I'm also curious what the devs have to say to this request. But to be clear: I don't want to change vanilla, I want to give mod authors more possibilities to change the feel of the game.

Regarding chest performance: Filters on containers were added in 1.1.62 for mods to configure
Added support for container entities with filters by using inventory_type = "with_bar" or "with_filters_and_bar".
If devs cared about performance of chests they could improve it a lot by adding some short-circuit logic to process empty slots at the end of the storage container faster. Afaik the game loops over all slots when moving items into or out of chests, even if their size is restricted by the red bars. With those modded huge containers or merged chests this becomes an performance issue real quick, even if the chests are almost empty.

Re: Restrict item storage and transportation

Posted: Sat Feb 18, 2023 11:53 pm
by FuryoftheStars
SWeini wrote:
Sat Feb 18, 2023 9:21 pm
But to be clear: I don't want to change vanilla, I want to give mod authors more possibilities to change the feel of the game.
It wouldn't need to be a "change" to vanilla, but in order for it to be supported, they'd have to add some checks somewhere that will run in vanilla and they have said no to simple changes like that before if they affect an entity that often sees wide spread use (and has no benefit to vanilla).
SWeini wrote:
Sat Feb 18, 2023 9:21 pm
Regarding chest performance: Filters on containers were added in 1.1.62 for mods to configure
Added support for container entities with filters by using inventory_type = "with_bar" or "with_filters_and_bar".
That's not how I interpreted that. That sounds to me like something they've added for container entities that already have filters. But that requires further clarification from someone in the know, or a clear demonstration of proof, not just us guessing.
SWeini wrote:
Sat Feb 18, 2023 9:21 pm
If devs cared about performance of chests they could improve it a lot by adding some short-circuit logic to process empty slots at the end of the storage container faster. Afaik the game loops over all slots when moving items into or out of chests, even if their size is restricted by the red bars. With those modded huge containers or merged chests this becomes an performance issue real quick, even if the chests are almost empty.
So, first, I want to point out that we don't actually know for sure how the devs iterate over chests. I've not seen a dev say explicitly how they do it, and everyone I've seen commenting on it are just guessing (they don't have acces to the code). I have, however, seen the devs mention that chests are optimized, though your guess is as good as mine on if they're as optimized as they can be.

That said, keep in mind that while slots that are marked red may be unavailable to inserters and bots to insert to, a player can still manually insert into these slots and inserters and bots can take from them. And as for shortcutting empty slots, remember that chests don't auto sort, so a chest with mixed contents can easily have gaps open in it as well as a player can also manually insert into any of the empty slots, like the last slot.

Re: Restrict item storage and transportation

Posted: Sun Feb 19, 2023 12:16 am
by Silari
FuryoftheStars wrote:
Sat Feb 18, 2023 11:53 pm
SWeini wrote:
Sat Feb 18, 2023 9:21 pm
Regarding chest performance: Filters on containers were added in 1.1.62 for mods to configure
Added support for container entities with filters by using inventory_type = "with_bar" or "with_filters_and_bar".
That's not how I interpreted that. That sounds to me like something they've added for container entities that already have filters. But that requires further clarification from someone in the know, or a clear demonstration of proof, not just us guessing.
There weren't any Container types with filters prior to that, as Container's could never be filtered. Only Vehicle subclasses, or the Character class, could. See the thread where it was implemented or this thread which shows a chest with filters.

Re: Restrict item storage and transportation

Posted: Sun Feb 19, 2023 2:00 am
by FuryoftheStars
Silari wrote:
Sun Feb 19, 2023 12:16 am
FuryoftheStars wrote:
Sat Feb 18, 2023 11:53 pm
SWeini wrote:
Sat Feb 18, 2023 9:21 pm
Regarding chest performance: Filters on containers were added in 1.1.62 for mods to configure
Added support for container entities with filters by using inventory_type = "with_bar" or "with_filters_and_bar".
That's not how I interpreted that. That sounds to me like something they've added for container entities that already have filters. But that requires further clarification from someone in the know, or a clear demonstration of proof, not just us guessing.
There weren't any Container types with filters prior to that, as Container's could never be filtered. Only Vehicle subclasses, or the Character class, could. See the thread where it was implemented or this thread which shows a chest with filters.
Well, depending on your interpretation, logistic storage chests do have a logistic filter. :) I think when I was first reading and responding to that, too, I was was conflating container with inventory (ie, I was thinking cargo wagons were included in that statement). Thanks, though, I completely forgot about that thread and honestly didn't know how they went about implementing it (I didn't research further back then). I see now that it's a property switch that they've added to the containers. I'm not sure if the problem this thread wants to address can be done the same way or not. I'll leave that to the devs as they know the inner workings.

TBH, I'm kind of surprised they did it considering they were against it before, and they've said no to other suggestions that amounted to the same idea: a simple IF check to see if the entity had it or not. Glad they're starting to go back on that. :)

Re: Restrict item storage and transportation

Posted: Sun Feb 19, 2023 11:57 am
by jodokus31
It's not directly connected, but here is a mod, that allows trains to be deployed differently:
https://mods.factorio.com/mod/trainConstructionSite

"This mod introduces a more realistic way of building trains."

I didn't test it and I don't know, if trains are not allowed to be stored in chest. But maybe it's an example of a different approach

Re: Restrict item storage and transportation

Posted: Sun Feb 19, 2023 2:22 pm
by FuryoftheStars
jodokus31 wrote:
Sun Feb 19, 2023 11:57 am
It's not directly connected, but here is a mod, that allows trains to be deployed differently:
https://mods.factorio.com/mod/trainConstructionSite

"This mod introduces a more realistic way of building trains."

I didn't test it and I don't know, if trains are not allowed to be stored in chest. But maybe it's an example of a different approach
Yeah, I've seen this. I don't think it does prevent trains from being stored in chests, but I haven't been able to use it much because it has some bugs or mod conflicts that went unfixed at one point so I disabled it. I need to check it out again....