Skip to content

Working with Player’s Inventory Using Visual Scripting

Since Balancy has built-in Inventory for user profiles, eventually there might be the need to access Inventory from Scripts to create some personalised User Experience and/or use fine-tuned personalised monetisation approach.

Balancy's Visual Scripting system supports Inventory by providing the following nodes:

  • Add Items - puts items to inventory
  • Remove Items - removes items from inventory
  • Get Item Count - returns the amount of given items in inventory
  • On Item Count Changed - trigger node for monitoring items count change
  • Wait Item Count - waiting node for triggering on given amount of items

See below some examples of practical usage for these nodes.

Contextual Offer

This is how we could track character’s health and make an offer to either use Health Potion, or buy more health potions to use them on-the-go, if there are no more in Inventory:

Contextual Offer

This script uses Get Item Count and Remove Items nodes.

  • During the game session character’s health could become low, so we check the amount of health and wait until it will be almost gone;
  • Then we check if the player has any healing potions in Inventory;
  • If they have, we offer them to use one, and in case of usage – remove one item from Inventory, restoring health to full;
  • If they don’t have potions, we offer them to buy one, and in case of purchasing – restore health to full;
  • If the player ignores these offers, we wait until character’s health will refill in any other way (with time, or by restarting the game) and go back to tracking health amount;

Tracking Deficit

This is how we could track the particular item reaching its deficit to show contextual offer to the player:

Tracking Deficit

The script uses Wait Item Count and Add Items nodes.

  • First we wait until the amount of Dark Elixir items in Inventory will become less than 5;
  • In that case we activate the offer with a pack of Dark Elixir;
  • If the offer was purchased, we add all items from the offer into Inventory;
  • After that (or if the offer was ignored), we wait for 1 hour and reset the script to get back to monitoring items count, so we’ll have a chance to repeat the offer by the same condition;

Progression Offer

This is how we could react to some milestones reached during the changing of amount of the item:

Progression Offer

This script uses On Item Count Changed node.

  • First we wait for any change in amount of the item;
  • Then we check for particular milestone values;
  • Each milestone will be a trigger for an offer with a different discount depending on it;
  • After all cases are worked through, we get back to the beginning to continue checking for any changes;