[1.1.87] Fluids get deleted when switching recipes but not when resetting recipes

Post Reply
Zaspar
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sun Oct 09, 2022 7:14 pm
Contact:

[1.1.87] Fluids get deleted when switching recipes but not when resetting recipes

Post by Zaspar »

Resetting an oil refinery's basic oil processing recipe will push out up to 100 crude into the pipe it's connected to (or more if the pipe has more capacity but default vanilla pipes have a capacity of 100). However, when pasting the recipe for advanced oil processing onto the refinery using shift+left click, with all other conditions unchanged, no oil is pushed out into the pipe. This inconsistency leads to the most efficient way to switch recipes on oil refineries to be to unset all the recipes first, before switching to advanced oil processing, which is obviously a silly thing to do. The reason I would consider it a bug though, is that it is inconsistent behaviour (the two very similar actions give strangely different results). It does not matter whether there is water in the second input, the result is exactly the same.

This video should completely describe the issue. Please let me know if any other info is missing. Thanks

https://www.youtube.com/watch?v=AeIukbUTvmw

mmmPI
Smart Inserter
Smart Inserter
Posts: 3147
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: [1.1.87] Fluids get deleted when switching recipes but not when resetting recipes

Post by mmmPI »

Zaspar wrote:
Wed Nov 29, 2023 3:28 pm
My bad, I should have written some more detail to go along with the video. I will add that in a separate reply so that it can appear from searches.
The video explains well the situation, but it doesn't fit the template at all ( the one called READ BEFORE POSTING ;) ) viewtopic.php?f=7&t=3638

When i saw it i thought maybe it could be due to the pasted receipe trigger fluid mixing check, the pipe in which the crude oil should be pushed back in your expectation maybe is reserved for water which cause different behavior in the 2 situations ? that's like Qon question


You could still edit your original post to add the missing things from the template, it would also work for searchs when a dev look after some reports that could be related/duplicate.

It's not causing crash or corrupting savefile or desync, it's a minor inconvenience in my eyes although your explanation for TAS makes perfect sense it could explain also why it wasn't considered high priority fluids are considered infinite and there exist other occurences of fluid being deleted due to roundings or fluid/mixing logic deemed not game-breaking, i would not expect this to change at least before the expansion, and would do the TAS accordingly. ( isn't it possible to reset receipe first to get the crude out, and immediatly after but in the same game tick or the one after switching the receipe ? )

Edit : the thread was changed but i didn't receive notification when posting and upon submiting i was answering the other one !

Rseding91
Factorio Staff
Factorio Staff
Posts: 13347
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.87] Fluids get deleted when switching recipes but not when resetting recipes

Post by Rseding91 »

Thanks for the report. I looked into this but it's a complicated one due to how assembling machines use fluid boxes and I don't have a nice fix.

When removing a recipe the code path is clear: "first push all fluids away, then remove fluid boxes"

When changing a recipe it isn't so clear: "first add/remove fluid boxes to match the new recipe layout, if any fluids still in the fluid boxes after the change don't match then purge them."

In the change recipe scenario the fluidboxes may not even exist after the recipe has been changed because they got completely removed - so it can't "push away" a deleted fluidbox. Similarly fluid-boxes may have been moved between pipe connections as part of changing the recipe so the fluids would get pushed into the wrong pipes.

It works this way so fluid for a given recipe gets re-used for the next one if they are acceptable.
If you want to get ahold of me I'm almost always on Discord.

DarkShadow44
Filter Inserter
Filter Inserter
Posts: 330
Joined: Thu Jun 01, 2017 12:05 pm
Contact:

Re: [1.1.87] Fluids get deleted when switching recipes but not when resetting recipes

Post by DarkShadow44 »

Rseding91 wrote:
Thu Dec 28, 2023 2:01 pm
It works this way so fluid for a given recipe gets re-used for the next one if they are acceptable.
Using 1.1.110 and when I copy paste "lubricant from heavy oil" onto a chemical plant with "solid fuel form heavy oil" there is nothing re-used - the heavy oil is lost. Did something change or did I misunderstand? Items get reused - if they are on the exact same slot.

IMHO, when copy pasting a recipe, all possible items/fluid should get reused (even if in another position), and everything unusable gets pushed out (or put into player inventory)

I imagine a workflow like
  • Iterate over all fluid boxes, save type/amount of fluid and a reference to the connecting pipe
  • Delete fluid boxes
  • Add new fluid boxes
  • Iterate over all saved fluids - if there is a match for the current recipe, put it in. Everything else (or surplus) gets pushed out.
Similar for items.

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

Re: [1.1.87] Fluids get deleted when switching recipes but not when resetting recipes

Post by mrvn »

Why not do the following:

- first push all fluids away
- remove all fluid boxes keeping a list of remaining fluids
- add fluid boxes for new recipe (if there is a recipe and fluids)
- put back remembered fluid if there are matching fluid boxes
- forget about remaining fluids

This would unify the algorithm for clearing a recipe and changing a recipe. So hopefully that even shortens the code.

In case the recipe is set to something that can reuse the fluid then it is needlessly pushed away first. But it will flow back so no great loss. Better than some expensive fluid getting lost.

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

Re: [1.1.87] Fluids get deleted when switching recipes but not when resetting recipes

Post by mrvn »

DarkShadow44 wrote:
Wed Sep 04, 2024 4:52 pm
Iterate over all saved fluids - if there is a match for the current recipe, put it in. Everything else (or surplus) gets pushed out.
He mentioned that fluids can't be pushed out after deleting the fluid box. There is nothing to do the push with.

DarkShadow44
Filter Inserter
Filter Inserter
Posts: 330
Joined: Thu Jun 01, 2017 12:05 pm
Contact:

Re: [1.1.87] Fluids get deleted when switching recipes but not when resetting recipes

Post by DarkShadow44 »

mrvn wrote:
Wed Sep 04, 2024 11:03 pm
DarkShadow44 wrote:
Wed Sep 04, 2024 4:52 pm
Iterate over all saved fluids - if there is a match for the current recipe, put it in. Everything else (or surplus) gets pushed out.
He mentioned that fluids can't be pushed out after deleting the fluid box. There is nothing to do the push with.
That's where the "reference to the connecting pipe" comes in. You don't need to have the fluidbox, but it connects to something - keep a reference to that.

Post Reply

Return to “Fixed for 2.0”