[0.15.33] copy_settings resets filter inserter filters

This subforum contains all the issues which we already resolved.
Post Reply
aaargha
Filter Inserter
Filter Inserter
Posts: 330
Joined: Wed Dec 07, 2016 8:35 am
Contact:

[0.15.33] copy_settings resets filter inserter filters

Post by aaargha »

I've tried using copy_settings on some circuit controlled filter inserters for some UPS benchmarking and while it correctly copies the circuit settings is also resets the filters of all inserters. Copying using shift+right-click -> shift+left-click works as intended so I don't really see why this wouldn't do the same.

I've attached a savefile with a couple of filter inserters, below is the command I tried using, note that it correctly copies the circuit settings but not the filter settings.

Code: Select all

/c for _,ins in pairs(game.player.surface.find_entities_filtered{name="filter-inserter"}) do
	ins.copy_settings(game.player.selected)
end
Attachments
reset filter bug.zip
(1.93 MiB) Downloaded 43 times

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [0.15.33] copy_settings resets filter inserter filters

Post by daniel34 »

The bug is that calling copy_settings on an entity with the parameter set to the same entity will clear the filter.

Calling

Code: Select all

/c game.player.selected.copy_settings(game.player.selected)
while hovering over a filter inserter will clear the filter but keep the circuit conditions.

OP's code has the fault that it is called for every filter inserter on the map, including the selected one. If you first call /c x = game.player.selected with the left inserter selected, and then call /c game.player.selected.copy_settings(x) with the right inserter selected it will properly copy the filter and circuit conditions.

EDIT: Since it's only self-copying that triggers the bug the following command will do what OP intends to do, copying the filter and circuit conditions of the selected filter inserter to all other filter inserters on the map:

Code: Select all

/c for _,ins in pairs(game.player.surface.find_entities_filtered{name="filter-inserter"}) do
   if ins ~= game.player.selected then
      ins.copy_settings(game.player.selected)
   end
end
quick links: log file | graphical issues | wiki

aaargha
Filter Inserter
Filter Inserter
Posts: 330
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: [0.15.33] copy_settings resets filter inserter filters

Post by aaargha »

I don't even want to imagine the odds of me multiple times choosing the first inserter returned by find_entities_filtered as source, especially as my test map has about 6.4k inserters :) Thanks for clarifying that.

Also, thank you for the code snippet, I used a separate command to copy the filters after setting them as a workaround, so that is a much better solution.

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

Re: [0.15.33] copy_settings resets filter inserter filters

Post by Rseding91 »

Since this only happens when you make a mistake in the Lua code and the game doesn't have this problem I don't consider this a bug.

Copying settings from self to self could probably even be an error since there's literally no reason you should ever do it.
If you want to get ahold of me I'm almost always on Discord.

posila
Factorio Staff
Factorio Staff
Posts: 5202
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.15.33] copy_settings resets filter inserter filters

Post by posila »

Rseding91 wrote:Copying settings from self to self could probably even be an error since there's literally no reason you should ever do it.
Maybe it could be NOP

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

Re: [0.15.33] copy_settings resets filter inserter filters

Post by Rseding91 »

posila wrote:
Rseding91 wrote:Copying settings from self to self could probably even be an error since there's literally no reason you should ever do it.
Maybe it could be NOP
Ok, I changed it for 0.16 so it just does nothing if someone tries to copy settings from the same entity onto itself.
If you want to get ahold of me I'm almost always on Discord.

aaargha
Filter Inserter
Filter Inserter
Posts: 330
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: [0.15.33] copy_settings resets filter inserter filters

Post by aaargha »

Thank you, that feels much more reasonable :)

Keep up the great work guys and have a great day!

Post Reply

Return to “Resolved Problems and Bugs”