question

vivecuervo7 avatar image
vivecuervo7 asked

Condensing Cloudscript down? Or buy more action triggers?

Ok. I'm having a little trouble here, and I think I can work around it by purchasing extra Action Triggers, but I'd rather keep costs to nothing while still in development.

I currently am seeing errors for my Action Trigger when Player.AddedTitle. I obviously hit an Action Trigger limit if I try and grant the inventory items and set all statistics via Triggers. Any suggestions? I'm using a Character to hold the player's "Deck" (card based game), hence the call to create it.

Note: In a newer iteration, I've collapsed the Catalogs, so this only needs to be one call.

handlers.GrantPlayerCharToUseAsDeck = function (args) {
  var data = server.GrantCharacterToUser({
    PlayFabId: currentPlayerId,
    CharacterName: "Deck",
    CharacterType: "Deck"
  })
  
  server.GrantItemsToCharacter({
    CharacterId: data.CharacterId,
    PlayFabId: currentPlayerId,
    ItemIds: [
      "new player inventory"
      ]
  })
  
  server.GrantItemsToUser({
    PlayFabId: currentPlayerId,
    ItemIds: [
      "evilmushroom",
      "blacksmith",
      "knight"
      ]
  })
  
  server.GrantItemsToUser({
    PlayFabId: currentPlayerId,
    CatalogVersion: "Avatars",
    ItemIds: [
      "default avatar collection"
      ]
  })
  
  server.UpdatePlayerStatistics({
    PlayFabId: currentPlayerId,
    Statistics: [{
      StatisticName: "Avatar",
      Value: 111111
    }, {
      StatisticName: "Arena Score",
      Value: 0
    }, {
      StatisticName: "Arena Wins",
      Value: 0
    }, {
      StatisticName: "Arena Defends",
      Value: 0
    }, {
      StatisticName: "Levels Completed",
      Value: 100
    }, {
      StatisticName: "Hard Levels Completed",
      Value: 900
    }]
  })
};
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

First, it's important to point out that the design of the system was that all the items should be in a single catalog - hence, the reason it's "catalog version" and not "catalog ID". There are also certain things that simply won't work if you spread items across catalogs, like receipt validation (items need to be in the Primary catalog).

But next, I need to point out that inventory operations do take more time, the larger the player inventory gets. And revoked/stacked items count as part of the inventory, until they're garbage collected. That doesn't take a long time, but it does mean that if you make frequent changes to the inventory, that's less efficient.

Finally, all the items across all the characters a player owns are effectively in one inventory, as far as the backend is concerned - they're just filtered in the calls according to the characters. But the base entity is the player, not the character, so all items are actually stored at that level, in real terms. So back to what I said above - if the inventory is large, that means operations will take longer. But you need to think of the inventory as all items across the player and all characters the player owns.

We're working on some potential future updates to the inventory system to help optimize this, but that's the way to think about this right now.

So, when testing, it's a good idea to create a player with your worst-case (largest) inventory, especially for purposes of testing Cloud Scripts (and even more so if you're trying to grant items from a PlayStream Action-triggered Cloud Script, since they get less CPU time, due to the fact that they can be called much more frequently). If you find that the scripts are taking too long, you'll need to either scale back the work they do, or else consider other options, like using a custom game server to control that part of the logic.

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.

vivecuervo7 avatar image vivecuervo7 commented ·

Thanks for the reply. I have certainly collapsed the Catalogs, making more use of the ItemClass. I was more thinking about the initial setup of a player, but it seems Action Triggers are the only way to go, performing the addition of Character (and then his Inventory) in the cloudscript, and then placing additional triggers to set initial values for all the statistics and also delivering default inventory to the player. Not an issue, unless it takes me ages to get the game to market and costs add up over time.

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.