DJPaul Posted May 23, 2015 Share Posted May 23, 2015 The Inventory:GetNextAvailableSlot method is very helpful for finding empty inventory slots for items to go in (it handles stacks, too, which is very, very useful). Unfortunately, the backpack object seems to be an Container component instead of an Inventory component, and so doesn't have this method or an equivalent. Not knowing if there's a formal feedback system for suggesting mod API improvements: Klei, please add an equivalent of Inventory:GetNextAvailableSlot to the Container component. There's some precedence for this, because a GiveItem method exists in both components. The use case is finding the best (possibly empty) slot for an item to be placed in, in the player's backpack or in chests. Link to comment https://forums.kleientertainment.com/forums/topic/54317-klei-please-add-inventorygetnextavailableslot-for-container/ Share on other sites More sharing options...
Corrosive Posted May 24, 2015 Share Posted May 24, 2015 @DJPaul, While the inventory component itself isn't a container, its item slots are a container, and the equip slots are a different container.GetNextAvailableSlot actually also checks the overflow container for available slots. (Backpacks are considered your inventory's overflow container, when they're equipped). GetNextAvailableSlot returns two values, the first is the slot, and the second is the container that it found free space in. The container can be itemslots, equipslots, or overflow. Link to comment https://forums.kleientertainment.com/forums/topic/54317-klei-please-add-inventorygetnextavailableslot-for-container/#findComment-640088 Share on other sites More sharing options...
DJPaul Posted May 24, 2015 Author Share Posted May 24, 2015 Thanks; I think my suggestion has some merit for it, which is why I started a topic. My proposed use case is finding the best slot in a chest or backpack (etc), not just the best slot within a player's overall inventory space (which may be within the backpack, as you said). It's easy, certainly, to create your own function that does this (I have), but it feels like a hole in the mod API. Link to comment https://forums.kleientertainment.com/forums/topic/54317-klei-please-add-inventorygetnextavailableslot-for-container/#findComment-640161 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now