Tolin Simpson avatar image
Tolin Simpson asked

CustomData in Catalog and ItemInstances Questions

Back in July I asked this question:

and since then this became a feature:

So coming back to finish our title's inventory system in September and deciding my original question didn't really reach the conclusion I wanted, I started looking around for other similar questions since then but with every helpful thread I found I kept getting more and more questions.

Here is how our titles inventory system works:

The system has items, some items have customData say a weapon or piece of armor and these have stats defined as customData in the catalog, when an item is granted we generate randomized stats based on rarity (we also generate rarity even after drop tables already do this so I put in this request: )

when granting the item we want to set the custom data for that item instance but first we need to get the customData from the catalog version of the item we are granting as the global "base stats" of the item with the customData based on the rarity being the "modifier" of those base stats. To do this we need to do this:

and before I found that thread I had this in my cloud script:

var getCatalogItemsResponse = server.GetCatalogItems({CatalogVersion: null});

var catalogItems = getCatalogItemsResponse.Catalog;

var length = catalogItems.length;

var catalogItemInstance;

for(var i = 0; i <= length; i++)
if(catalogItems[i].ItemId) == itemId)//itemId being the item id of the item we are granting (these are all unique in the catalog). Note: I tried JSON.parse(catalogItems[i]) and got errors.
catalogItemInstance = catalogItems[i];


So I have to iterate through all the catalog items to find the catalog item with the ID matching the Id of the item I am trying to grant and set itemInstance customData for. I can't seem to get the ID off the catalog item instance though.

This also helps determine what kind of stats the item has.


var ItemStat = catalogItemInstance.CustomData["keyname"] * rarityModifier;

when granting the item we would set ItemStat as the value of a customData key in the itemInstance before it is added to the inventory.

The end result I am trying to get is:

1) catalog items with the universal "base stats", when these are changed all item instances apply their rarity modifiers to the new base stat.

2) All ItemInstances in the players inventory are unique to almost all other items in other players inventory (random stats/rarities) and I can access the customData that is in the inventory itemInstance we defined when granting the item for use in gameplay mechanics.

I would like it if someone can lay this all out for me or share how they did this or something similar, I'm sure a lot of people have similar questions but it seems every answer I find gives me several more questions.

CloudScriptIn-Game Economy
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

So, the specific way to do this is as you describe:

First, get the catalog for the title, so that you have the base information to work with.

Next, calculate what all the custom properties will be for the item instances you're granting to the player.

Finally, grant the items with the custom data, as described here:

When you retrieve the catalog, what you're getting is an array of item descriptions. Each description is already a JSON object, with all the properties, so there's no need to parse() it - that's just for turning a string containing JSON into a JSON object. Now, the CustomData property on the items in the catalog are strings (, so if you're storing the information on the data you want to be able to set on the item instances in JSON format in CustomData, you would indeed need to use parse() on that, to get a JSON object containing your info, so I suspect what you're looking for is this:

catalogItemCustomData = JSON.parse(catalogItems[i].CustomData);

So that you could then dereference the actual elements like this:


Is that the part that's tripping you up? If not, can you clarify what your questions are?

10 |1200

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

Tolin Simpson avatar image Tolin Simpson commented ·

Yes that part was tripping us up, we would also like to know if itemInstances we wrote custom data for if we make balancing changes in the catalog is there a way we can recalculate the custom stats (maybe subtract the old catalog "base stat" then set aside the stats value after than then add it to the new "base stat" in the updated catalog.) all new items would have the updated catalog stats but the old items would still be using the old catalog custom data before the multiplier was applied. But how can we check if the catalog if the catalog had a change if we can't make balancing changes is there a way to remove all the unbalance items based on what catalog version they came from although we don't want to do anything that drastic.

0 Likes 0 ·
brendan avatar image brendan Tolin Simpson commented ·

No, the purpose of the CustomData between catalog and item instance are very distinct - the catalog data is for global info, while instanced data is for things that must be unique on the item itself. If you want to be able to make adjustments later, you'll want to use the catalog's data as the way to do that. The way to accomplish this for a system where you set item instance data based upon the catalog data, but still be able to adjust it for all players later, would be to have the data stored on the item instance be relative to the catalog data. So for instance, if you store the item data as being a value that is added to the catalog's base data, or a percentage value used to calculate the item's data based on the range available in the catalog data, that would allow you to do this.

0 Likes 0 ·
Tolin Simpson avatar image Tolin Simpson brendan commented ·

Actually looking back at this, what was tripping us up in the code above was that we could not get the itemId of the catalog itemInstance using catalogItems[i].ItemId.

(Mid-thought...we probably don't need this..)

Other then to prevent some cheating I don't see why we don't just keep the base stats on the client and assign a percent modifier and just not bother with base stats in the catalog. This information might be helpful to someone else though seeing as in my case I will try the approach I just mentioned.

In theory you could have a check when logging in to see if the catalog has updated, then when the player loads their inventory update the customdata based on the new catalog stats if someone wants to push for some extra security.

0 Likes 0 ·
Show more comments

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.