Page 1 of 1

[1.1.81] LuaEntity.set_filter does not update open GUI

Posted: Sun May 21, 2023 6:53 pm
by Nagrom_17
Calling set_filter on a LuaEntity does not visually update the filter slots in an already open entity gui.

What did you do? Call set_filter(1, "iron-plate") from a Lua Snippet with a filter inserter gui open.
What happened? The filter slots on the filter inserter do not visually update to reflect the new filter. The entity preview and in game sprite correctly update.
What did you expect to happen instead? The filter selection slots should always visually match the actual filters
Does it happen always, once, or sometimes? Always

Reproduction steps:
Open entity gui of filter inserter
call entity.set_filter(...)

A save file is provided with a Lua Snippet to accomplish this.
Screenshot 2023-05-21 133409.png
Screenshot 2023-05-21 133409.png (1.21 MiB) Viewed 1206 times

Re: [1.1.81] LuaEntity.set_filter does not update open GUI

Posted: Thu Oct 19, 2023 9:06 pm
by test447
+1 to this. I was recently using https://mods.factorio.com/mod/FilterHelper and while it's super helpful, it has to close and reopen the GUI to refresh the changed filter because of the behavior described here.

Specifically it would be really nice if the GUI for an opened inserter, splitter, or loader would refresh after https://lua-api.factorio.com/latest/cla ... set_filter is called by a mod on that entity.

I see that this same thing was done in the past for constant combinators and set_signal in viewtopic.php?f=65&t=89218&p=511616 so it'd be awesome to see it done for inserters/splitters/loaders and set_filter too!

Re: [1.1.81] LuaEntity.set_filter does not update open GUI

Posted: Thu Oct 19, 2023 9:34 pm
by test447
For the sake of completeness I went into a no mod game in 1.1.93 and checked the following.

Starting with a map with the filter inserter, stack filter inserter, splitter, and loader:
starting_point.png
starting_point.png (6.32 MiB) Viewed 914 times
And then with this lua script in the editor for removing the filter by script:
```lua
local surface = game.player.surface
local entities = surface.find_entities_filtered{ area = area }
for k, entity in pairs(entities) do
entity.set_filter(1, nil)
end
```
Opening the filter inserter and then running the script over it resulted in the GUI being unchanged:
filter_inserter.png
filter_inserter.png (5.27 MiB) Viewed 914 times
Same with the stack filter inserter:
stack_filter_inserter.png
stack_filter_inserter.png (5.25 MiB) Viewed 914 times
Same with the splitter but for it I had to use the `splitter_filter` lua property instead of the `set_filter` function so the script looked like this:
```lua
local surface = game.player.surface
local entities = surface.find_entities_filtered{ area = area }
for k, entity in pairs(entities) do
entity.splitter_filter = nil
end
```
splitter.png
splitter.png (5.53 MiB) Viewed 914 times
Same with the loader but back to using `set_filter` again:
loader.png
loader.png (5.75 MiB) Viewed 914 times
So it would be really cool if writes to https://lua-api.factorio.com/latest/cla ... ter_filter also were reflected in the open GUI too in addition to calls to set_filter.

Re: [1.1.81] LuaEntity.set_filter does not update open GUI

Posted: Mon Jan 22, 2024 1:55 pm
by boskid
Thanks for the report. This issue is now fixed for 2.0: set_filter(call) for inserter and loader and splitter_filter(write) for splitter were fixed to refresh GUI correctly.