[1.1.81] LuaEntity.set_filter does not update open GUI

Post Reply
Nagrom_17
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri Sep 28, 2018 8:15 pm
Contact:

[1.1.81] LuaEntity.set_filter does not update open GUI

Post 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 798 times
Attachments
factorio-current.log
(6.14 KiB) Downloaded 41 times
filter-inserter-bug.zip
(1.34 MiB) Downloaded 41 times

test447
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed May 05, 2021 8:11 am
Contact:

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

Post 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!

test447
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed May 05, 2021 8:11 am
Contact:

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

Post 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 506 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 506 times
Same with the stack filter inserter:
stack_filter_inserter.png
stack_filter_inserter.png (5.25 MiB) Viewed 506 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 506 times
Same with the loader but back to using `set_filter` again:
loader.png
loader.png (5.75 MiB) Viewed 506 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.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2247
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

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

Post 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.

Post Reply

Return to “Fixed for 2.0”