Page 1 of 1

How to detect if an item has been put in or removed from a particular chest?

Posted: Wed Nov 14, 2018 8:58 pm
by Pebble
Hi,

So I sort of inherited an old mod that used on_tick to poll all of the mod's chests (Blueprint Reader) to see if a blueprint is placed in the chest, and it updates the circuit network based on that.

I already have reliable events for the creation and destruction of the chest, and am properly handling that.

I would like to remove the polling behavior, and rely on events to tell if a blueprint is in the chest or not, but it seems like there are no adequately descriptive events that are appropriate for this.

I want to know what combination of events I need to check for to detect whether a blueprint is placed into the chest inventory or removed, and maybe a better understanding of the behavior of those events, because the API descriptions were all of maybe 10 words each so I don't really get what they cover?

Re: How to detect if an item has been put in or removed from a particular chest?

Posted: Thu Nov 15, 2018 11:43 am
by eradicator
Two scenarios:

a) can inserters put stuff into the chest and/or is that relevant to your mod? → you're out of luck, there is no event you can use.

b) can only the player input/output stuff into the chest? → you might be able to hack something with on_gui_opened and on_selection_changed, but you'll still need at least a dynamic tick handler to track changes while the chest is in use by a player.