question

Joshua Strunk avatar image
Joshua Strunk asked

ItemInstance, BundleContents vs BundleParent

I noticed that the field BundleContents of ItemInstance is returning the ItemId for items, while the field BundleParent of ItemInstance is returning the ItemInstanceId. I am wondering if this is correct? The documentation for ItemInstance while vague gives the impression this should be the other way around.



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

I'll get the tools team to update the documentation to clarify that. The BundleParent is an Item Instance ID because it is reliably unique. The BundleContents is an array of ItemId values for the items added. This is because it would get potentially confusing if this were Item Instance ID values, in the case of stackable items. Say you have a stackable item "foo" which is added by "Bundle1". If a player already has a stack of item "foo" in his inventory, and he's then granted a "Bundle1", if we returned the Item Instance ID which the "foo" item was just added to, that would mean returning an Item Instance ID for something that was already in the player inventory - it wasn't added by the grant of the bundle, the grant just resulted in incrementing the count of the item. So we return the ItemId to allow the title to know specifically what was added.

10 |1200

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

Joshua Strunk avatar image
Joshua Strunk answered

Thanks for clarifying this and explaining the why. Its always nice to know the rational behind the why the API behaves the way it does.

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.