Inventory Spawned Items Lifespan?

I want to collect apples in my inventory. I spawn them in cartain places around the world and the player can pick them up. However, I am having trouble setting a lifespan for these objects inside the slot-based inventory.

When the apple lifetime expires, all the apples I have in the inventory disappear, besides having been picked up at different spawn times. I want them to expire and be removed one by one, according to when they were collected.

What am I missing??

do the slots in your inventory get created using a separate slot widget? like for example creating a slot widget for every item using a forloop? i think yes.

if that is the case then its easy. each slot widget is a different instance so you can have functions running on them and they would act independently.

1-) So what i think you should do create a variable named id in slot widget and then using the forloop, on each widget slot creation take the id reference from the widget slot and set it to the forloop’s index :slight_smile:

2-) next in the slot widget on construction check the item in your inventory at the id and check its expire time and use that time with something like time elasped or something and then when a specific time is reached remove the item from your inventory using id variable in your inventory.

maybe there is a efficient way of doing and maybe im over complicating it a bit but its actually a pretty easy and small change when you actually try setting it.

Ask For a screenshot if needed

Yeah, I would like any more info you can offer! It seems doable so I’m very interested! For example I thought there would be something with loops but I’m not very experienced in them. Oh and yes, my inventory does have a separate slot! I based it on Ryan Laley’s tutorials and the base code is still pretty much the same as we speak!