Having trouble modifying player.auto_trash_filters

Place to get help with not working mods / modding interface.
Post Reply
Tain
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 16, 2014 5:46 am
Contact:

Having trouble modifying player.auto_trash_filters

Post by Tain »

the example from the API works as intended, fully replaces the current auto trash with what is in the new table.

Code: Select all

game.player.auto_trash_filters = {["iron-plate"] = 20, ["copper-cable"] = 42}
But I can't seem to modify the existing table, only replace it.

Code: Select all

game.player.auto_trash_filters["iron-plate"] = 20
doesn't work

Code: Select all

print(game.player.auto_trash_filters["iron-plate"])
does work

I've tried a lot of variations on this, using dot notation or character instead of player; all with the same results.

how can I modify a single entry of the table, but leave everything else?

Also what is the event for modifying player logistic/auto trash slots?

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Having trouble modifying player.auto_trash_filters

Post by Nexela »

It is either replaced with the new table (like fluid boxes, but typically the api would tell us), or the table needs to be edited directly


local filters = game.player.auto_trash_filters

--modify filters table

if it needs to replace then:
game.player.auto_trash_fiters = filters

Tain
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 16, 2014 5:46 am
Contact:

Re: Having trouble modifying player.auto_trash_filters

Post by Tain »

copying to a local variable, then replacing worked for me. thanks!

do you know what event is triggered when the players logistic request/auto trash slots are modified?

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

Re: Having trouble modifying player.auto_trash_filters

Post by Rseding91 »

Tain wrote:copying to a local variable, then replacing worked for me. thanks!

do you know what event is triggered when the players logistic request/auto trash slots are modified?
There is none.
If you want to get ahold of me I'm almost always on Discord.

Tain
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Nov 16, 2014 5:46 am
Contact:

Re: Having trouble modifying player.auto_trash_filters

Post by Tain »

Rseding91 wrote:
Tain wrote:copying to a local variable, then replacing worked for me. thanks!

do you know what event is triggered when the players logistic request/auto trash slots are modified?
There is none.
So if I want to do something when that happens, I would need to use on_tick and then somehow check if the slots have been modified manually?

mophydeen
Filter Inserter
Filter Inserter
Posts: 529
Joined: Sun Nov 22, 2015 5:02 pm
Contact:

Re: Having trouble modifying player.auto_trash_filters

Post by mophydeen »

Tain wrote:
Rseding91 wrote:
Tain wrote:copying to a local variable, then replacing worked for me. thanks!

do you know what event is triggered when the players logistic request/auto trash slots are modified?
There is none.
So if I want to do something when that happens, I would need to use on_tick and then somehow check if the slots have been modified manually?

yes

Post Reply

Return to “Modding help”