Forum rules - please read before posting.

Limiting Inventory Item Ownership by Category

Hi Chris,

First off, happy New Year to you and yours, and many thanks for the stellar service that you've provided here last year (and indeed ALL the years)

Secondly a small question:

I want to limit the amount of items in a particular Category that a Player can have in their Inventory. Kind of like "Can carry multiple?" but for Categories rather than individual items. For instance I only want them to be able to carry around a single Outfit at any one time

In this game Outfits will only be available from within Containers, so I'm using "OnContainerRemove" to check if the Player is trying to take an item which they already own in the relevant Category, out of a Container

I've got it all working, but can I just confirm that at the point where OnContainerRemove is called, the selected item has already been added into their Inventory?

I'm pretty sure that's the case, because the only way I can get it all to work, is to check if they already own an item in the "Outfits" Category (which isn't the item that they're trying to take), and, if they do, then I Remove the added item from their Inventory and Add it back into the Container, to restore the status quo

As I say, I seem to have got it all working, but my approach just seems a wee bit... inelegant. So I was wondering if there might not be a better way of approaching the problem?

Comments

  • happy New Year to you and yours

    Thanks, and to you!

    I was wondering if there might not be a better way of approaching the problem?

    OnContainerRemove is indeed called once the transfer has taken place. However, I've been looking into improvements to the Container system as part of the upcoming v1.70 update.

    As part of these improvements, I'm adding a new function to the RuntimeInventory script named "CanTransferContainerItems", which can be used to determine if the transfer is currently allowed. This function would be virtual, allowing you to override it via subclassing, so that you can simply check if the player already carries an item of the same category.

  • cool. thanks chris. that sounds like it would be just the ticket. i'll keep an eye out for the latest release

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.