question

tombatsford avatar image
tombatsford asked

Default custom data on item instances.

Hey,

I am working with trying to add some default custom data on item instances that is always the same for an individual item. I have worked out that we can use the items custom data in the catalogue for setting default custom data per item instance. The issue i have however is that none of this catalogue custom data is returned when i get a users inventory using the relevant API call. What would be the best way to get the data set in the catalogue custom data for an individual 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.

1 Answer

·
brendan avatar image
brendan answered

The issue is the fact that we didn't name them differently - something we'll fix in a future update, to help with this. Here's how it works:

Custom data on a catalog item: This is global data, which exists only in the catalog. It is here so that all users have the same values. If you modify it here, all players are then using the updated value. It is not copied to instances when they are created.

Custom data in an inventory item instance: This is unique to the single item instance in question. It can be set via UpdateUserInventoryItemCustomData or GrantItemsToUsers.

For your case, I'd recommend just using the catalog version of the data until you override the player's item instance with its own custom data.

2 comments
10 |1200

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

plourdegui avatar image plourdegui commented ·

What would be the best practice for defining default "instance default data" then?

My use case is as follow:

For a given user item, I need to mark it with a "isNew" field which indicates whether the player has seen the item yet.

I would like such field to be part of the "instance custom data" and be set to false by default when it is first added to the player inventory.

Then, when the player "sees" the item for the first time, I would issue a UpdateUserInventoryItemCustomData via a CloudScript to update the value to of the "isNew" field to "false".

If there is no way to set "default instance data", Is there an alternative?

Regards

0 Likes 0 ·
brendan avatar image brendan plourdegui commented ·

Then I would recommend making the logic be "if isNew is null or true, the item is new", and set it to false when the player specifically views the item.

0 Likes 0 ·

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.