Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Best way to handle zero quantity Items?

edited February 2 in Technical Q&A

I've got a lot of Inventory Items in my current project which act as "containers", e.g. a gun can contain 6 bullets, a bottle of beer can contain 3 swigs (adventuring is thirsty work), etc etc

At present I handle this by sync'ing each amount to a corresponding Global Variable, and that all works fine

The problem is, that when the amount reaches zero, the Item simply disappears from the Inventory, whereas in RL you'd be left with an empty gun, or beer bottle, or whatever

One option (the easy one), would be to just pop up a message saying that the player tosses the Item away like a contemptible litter-lout

A second option would be to add an extra "Empty" Inventory Item for each Item, and add that to the Player's Inventory when the real Item's amount reaches zero. I'm experimenting with that possibility at the moment, but I can already see it getting really messy really fast

A third option would be for AC to allow zero-quantity amounts in the Inventory, but I can see that one might be undesirable due to its potential for breaking existing functionality

Are there any other possibilities for handling the situation that I'm overlooking though?

Comments

  • A third option would be for AC to allow zero-quantity amounts in the Inventory, but I can see that one might be undesirable due to its potential for breaking existing functionality

    Correct. This wouldn't be something I'd be looking to implement.

    A second option would be to add an extra "Empty" Inventory Item for each Item, and add that to the Player's Inventory when the real Item's amount reaches zero. I'm experimenting with that possibility at the moment, but I can already see it getting really messy really fast

    Certainly in the case of a beer bottle, I'd lean towards this - as an empty beer bottle, named as such, would conceivably be treated as a separate item.

    The auto-addition of an "empty" variant could be automated through use of the OnInventoryRemove custom event - so that if a given item ID is removed, its empty equivalent is added.

    Are there any other possibilities for handling the situation that I'm overlooking though?

    Properties can be defined in the Inventory Manager, and then local values of each assigned to each item.

    These are read-only, however, though if they were modifiable I suppose these could serve the same purpose. I can't make promise on how possible this change may be, but I shall give it some consideration.

  • edited February 3

    Thanks Chris, I did originally look into using Inventory Properties for this purpose, and discounted them as they were read-only

    If it was at all possible, it would be absolutely AWESOME if they were updatable. I can think of a load of use-cases for that, including some things that I'm currently futzing around using Global Variables to achieve (the number of uses remaining of an item being just one example)

    For the time being, I'll probably stick to adding and removing "shadow" instances of these kinds of container items, updated via OnInventoryRemove (and OnInventoryAdd, to remove the shadow instance when a full Item is added to the Inventory), as you suggested

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.
Do NOT follow this link or you will be banned from the site!