susanw1 / Factorio-Inventory-Trim

A mod for Factorio that automatically frees inventory slots by removing insignificant excess quantities
MIT License
1 stars 0 forks source link

Ensure that stacks of items with different "qualities" aren't merged #33

Open susanw1 opened 1 week ago

susanw1 commented 1 week ago

I think we have a few tables for tracking stacks keyed by entity type. They should be "quality-aware".

Relevant? https://lua-api.factorio.com/latest/concepts/ItemWithQualityID.html

susanw1 commented 5 days ago

Note, comment here under How do I request all qualities?: https://www.reddit.com/r/factorio/comments/1gdym04/comment/lu6dtx3/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

You first have to switch the quality, then select the item Also the buttons that are not = are not usable for request

So looks like a player logistics request may ask for any quality, or a specific quality, but no complex '>' or '<' checks. Phew. I think they stack separately generally. Means we just need to add better table/item_name indexing, and check the any/specific cases. Might be fiddly...

susanw1 commented 3 days ago

So, one good thing: we use the stack2.transfer_stack(s1) function to combine stacks. That's unlikely to merge similar stacks different qualities, though that probably needs verifying. It's possible that the mod will keep trying, though.

One reasonable strategy is to assert that any quality > Normal is too important to trim. Just skip it, both in in the logistics request scan, and when scanning the main_inv. We need to make sure that any methods that take just an item_name (and don't qualify by quantity) do what we want.