Slots / Buyable Slots

What are Buyable Slots?

Buyable slots gives you the opportunity to offer additional optional storage slots that must first be purchased before they can be used. Buyable slots can be added to any storage component, and you can define the costs for each slot.

How to Setup Buyable Slots

For player storage components like inventory, hotbar and bank you will have the option to set your buyable slots in each of the categories in the configuration of the main AC_InventorySystem component you added to your player controller, such as InventorySlotCountBuyable integer and adding your costs to the InventorySlotCountBuyableRequirements array. You will find similar variables under hotbar and bank.

For everything else you can directly set how many buyable slots with the slotCountBuyableAvailable integer and the slotCountBuyableRequirements on the instance of the AC_Inventory_Storage component.

The integer is how you set the total number of slots you want to make available for purchase.

The requirements array elements correspond to the slot being unlocked. So if you offer 7 slots, 0 in the requirements array will be for the first slot, 1 in the requirements array will be for the second slot, and so on. This is up until your max price. If items share the same price after a certain point you can optionally leave out those extra arrays that would otherwise just be repeating data. The last requirement is used for all slots without a cost requirement defined.

Max price for buyable slots

To instigate a max buy price for your slots you can leave out any extra indexes in the requirements array.

For example if we want to sell our first slot for 1 gold, then all slots after will cost 100 pieces of cooked meat we only need 2 elements in the requirements array.

The first will be for our coin_gold with a quantity of 1, the second (and last element) will be used for all other buyable slots, which we would set to meat_cooked with 100 quantity. So if we had 7 total slots the last 6 would cost 100 meat_cooked each since there are only 2 elements in our requirements (our first slot discount, then the same price for all the rest).

It is worth noting that this is optional and you are welcome to define the same data over, it however can only be used to fill out the remaining on the list, it can’t be used to fill gaps.

How to make a buyable slot Free

So you want to give your player a free taste before digging in deep with the costs, to set a buyable slot to be free just leave the RequiredItems array empty for the requirements array index. For example our Bank gives us the first buyable slot for free. We define this by creating an empty item in the requirements array (no required items).

Each additional slot afterwards has a price, which is defined by the 2nd element in the requirements array.

Change Buyable Slot Counts

You can change the buyable slot count integer however the number of slots unlocked is what we track. If the player unlocks slots and you later roll down the maximum, the player will still have access to all of the slots they purchased by default.

You would need to implement a clamp using your max if you want to take these away from the player.

When it comes to decisions that influence the player experience I always try to write my code to favor the player's experience.

Bypass the Costs and Unlock a Buyable Slot Dynamically

There may come a time where you wish to award the player by unlocking a buyable slot without making them pay for the slot. To handle this you will call the addBuyableSlot function on the storage component, and set the BypassRequiredItems? boolean on the node to true.