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

Place to get help with not working mods / modding interface.
Pebble
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun Apr 15, 2018 8:21 pm
Contact:

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

Post 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?
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Modding help”