question

dragonfoundry avatar image
dragonfoundry asked

Stackable items aren't consolidated in inventory

When I convert items from non-stackable to stackable, the items don't get consolidated in the player's inventory. See player 9A7AE96546CEE8C4 in title 6263, and search for "Teddy Bomb" - there's multiple entries. All the entries link to the current, stackable, object.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

Correct - instances of items are distinct from the catalog. Think of the catalog as the definition for how items are to be created. When the items are instanced, they are created from that template. So if the item is not stackable when it is instanced, changing the catalog will not change the already-existing items. While I realize it seems unlikely that it would actually break an existing title, we cannot make potentially breaking changes to the service for non-critical issues.

The way to resolve this for your users is by using Cloud Script to replace the items in question, granting the ItemId in its new state and revoking the old instances. Since you can only revoke one item at a time, and you need to be careful not to have the scripts run too long or make too many API calls, this is going to need a client update, as well. Ideally, I would do it this way: When the client gets the inventory for the first time in a session, check it for this issue. If it has any items in this state, have it make a series of calls to Cloud Script over time to update the inventory to replace the item.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dragonfoundry avatar image
dragonfoundry answered

Here's the problem with that plan: I can't tell whether a version in the inventory is Stackable or not. That information doesn't appear in the inventory result.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

A fair point, though you do have the timestamp of when the item was added to the user inventory (PurchaseDate), so if you're pressed for time, you could determine it that way. Longer-term, we could add an "IsStack" boolean to the information returned in ItemInstance.

0 Likes 0 ·
dragonfoundry avatar image
dragonfoundry answered

Further question: If a stackable catalog object's info changes (for instance, an item class, expiry time, bundle contents, custom data), and then a player is granted another one, their version will still have the original attributes?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

Yes and no. Because stackable items stack onto their base, the base is what defines its static properties, so class, tags, image URL, description, and display name would all remain the same. However:

  • Bundle contents - Only the base item itself is the stackable. The items that are bundled with it are other items that just happen to come with it "for free". When you create an instance of the item, the items it is bundled with at that time are added to the player inventory as well.
  • Expiry time - Currently, there is a known issue with stackables which have an expiry time. When more items are added after the item has expired, it remains expired. We will be fixing that shortly so that stackable items work the same as items with a Usage Period Group. That is, when you add another item to the stack, the expiration time will have the time defined on the catalog ItemId at that time added to the remaining time before expiration.
  • Custom data - Custom data is not added to an item instance on creation. The CustomData in the catalog is there to be used as a global lookup for all instances, so that if you change it later, you're referencing the global data for everyone. CustomData on an item instance is added to it (or changed) by Server API calls after it is instanced.

If you need to change the static elements on a stackable, the current recommendation would be to move to a new ItemId (and again, then use Cloud Script to move the old items over). I'm adding a backlog item as well for an "overwrite base" option for catalog items, though I will caution that it will likely be some time before that bubbles up in the priority stack.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.