limit the slot capacity.

Hi everyone,

I am using the “Inventories” extension in GDevelop to manage my game’s inventory and I need some help to limit the slot capacity. Currently, I have two types of collectibles and when the player collects keys, they can collect them infinitely in the same slot. Instead, I would like to set a limit so that once the limit of 5 keys in one slot is reached, they move to the next empty slot.

Can someone explain how I can configure this functionality?

Thank you very much for your help!

Are you using the built-in inventory or one of the extensions. The first one adds features to the built-in while I believe the other 2 use their own unrelated methods.

Are you using a single row of slots or a grid? Which part(s) do you need help with save/load, add/remove or something else?

A snapshot of your inventory events and the scene setup will help you get a quicker and more specific reply.

thanks for the reply and your time,
I use a “Simple Inventories” extension
I’m using a row of slots, although I don’t know if the grid is convenient, unfortunately there are no guides to understand how these extensions work, or maybe I’m not aware of them.
I made the mistake of commenting in Italian so I don’t know if you can understand my current situation from the image I show you

I think I’ve seen your events in another post. Either way, I can get the gist of it through context.

Th first part checks if the item exist. If not, then the 2nd part checks for an empty slot.

If you can only find 1 key at a time then when you check if a spot already has the item then check the quantity in that slot is less than 5. This would require maybe an object variable for each spot or check the linked text. You would need to track that number separately from the number in the inventory.

If there’s under 5 in the slot then add it to the slot. If it’s not <4 then do nothing and the 2nd half should create a slot as if there are none

I’m not at my PC to test the concept. It shouldn’t require too much change. The inventory and slot inventory would be separate.

If you’re still stuck then I should be able to try my concept later when I’m at my PC.

1 Like

ok, I’ll try to do it thanks for the solution :slight_smile:

1 Like

I was playing with this earlier. It’s an interesting concept and I’m a bit weak with inventory. So, it’s a win-win.

Try me. Click the items to collect. You can hold the left button to keep picking items.

Source (click the green [code] and [download zip]

I’m not saying this is the best way. It needs testing and maybe tweaking.

I feel like it should be able to be trimmed down. I used the sticker behavior on the text to stick it to the slot so they could both be slid together. I’m not thrilled with that. Copying the value might be better. Although, I think I would add a count variable to the slot so the value in the text object was unimportant when moving items. It’s tough because I wanted simple and easy to read.

1 Like

Fantastic ! As soon as I get home I’ll try it straight away, even though I think it’s more than fine.
thanks for your time ^ ^

:star: :star: :star: :star: :star:

1 Like