Slots / Temp Slots

What are Temp Slots?

Temp Slots are conditionally available slots.

Temp slots will remain on the storage component until either you unset them or until the end of the current session, whichever happens first. Temp slots do not persist between restarts, and should manually be reapplied by related systems if needed after a restart.

For example, when you equip the Rocket Backpack in the Demo World you unlock 7 additional slots in the player's inventory. When you unequip, the slots go away. Under the surface this is using Temp Slots.

How to add Temp Slots

Temp slots are managed using the setTempSlots function found on the AC_Inventory_System component.

This function has the following inputs:

Amount the amount of slots would like to add.
Source a string used to identify what is making the change. The source is the grouping, so you will want to calculate the sum first if multiple sources influence it, then apply it using a unique source. If you leave the source empty it will use undefined as the source instead. Defining it lets you apply Temp Slots from multiple sources instead of just one.

How to Remove Temp Slots

Temp slots will remain until either the end of the session, or until you send an update through setTempSlots with an Amount value of 0 with your unique Source. Setting a value of 0 is effectively unsetting it.

How the Equipment System uses Temp Slots

As mentioned above, when we equip our Rocket Backpack from the demo content we unlock 7 additional inventory slots. Behind the scenes when equipment changes one of the things the equipment system does is recalculates the sum of all Values from equipment with the dynamic data key inventory.slots. Our RocketBackpack has this dynamic data key, with a value set to 7. It then takes this total value and uses the setTempSlots function on the player's inventory instance of AC_Inventory_Storage to change the temp slot count. It uses equipment as the Source for this call, including equipment as the source.

Then when we unequip the Rocket Backpack it redoes this calculation and comes up with 0, which it then reports to the setTempSlots function.