MaxStackSize - originalfoo/Prison-Architect-API GitHub Wiki

##Overview

The MaxStackSize setting, which is primarily used on Consumables, Statics, Utilities and Vehicles, determines whether they can be stacked and, if so, the maximum number of units that can be in a single stack.

##Syntax

This optional setting is used in materials.txt and must be within a BEGIN Object ... definition block. It can be used only once per definition block.

    MaxStackSize <number>

Where <number> is an integer defining how many units can be put in to the stack.

A default of MaxStackSize 0 will be used if the setting is not defined.

A value of -1 completely inhibits stacking, and is commonly used when defining Vehicles.

##Example

Allow up to 10 units to be put in to a stack:

    MaxStackSize 10

##Notes

Stacking allows multiple units of an item to be collected together in to a single object, improving game performance and de-cluttering the map.

A stack can only contain one type of item at a time. For example, if a stack contains Wood consumable then only Wood can be added to that stack.

There are two types of stack object:

Note: Materials define a ObjectRequired (specifically, a Consumable), and it's the Consumable that you see being delivered in stacks.

Effects on deliveries

Stacking greatly improves the efficiency of deliveries. For example, a [SupplyTruck](SupplyTruck (Vehicle)) only has 8 slots for cargo; if you order 10 items that are non-stackable, it will require two trucks to deliver them. If, however, those items had a MaxStackSize of 10, they would be delivered in a single stack, in a single slot of one truck that would then have 7 slots free for other items.

Effects on items already on the map

The [Log consumable](Log (Consumable)) is a good example of what happens to items already on the map. They start out as individual objects and will gradually be gathered in to stacks by [Workman entities](Workman (Entity)) as a low-priority task.

Effects on item consumption

When items are required for some construction or process, workers will gather either a stack or individual resources, whatever is most readily available.

If a stack is chosen, then units of the item will be removed from it as necessary. If the quantity of items in the stack reaches 0, the stack is automatically removed from the map.

Note that if the stack has available capacity, more items may be added to it at any time.

Effects on sprites

The sprites used for a stack differ depending on the type of stack:

  • Box stacks will always look like boxes: ** They have a small label on them and the sprite associate with their contents will be shown on the label ** Boxes can be .Opened which changes the sprite used for the box; but the label will remain
  • Stack stacks will use the StackSprite associated with their contents:
    • The piece of the sprite shown depends on the quantity of items in the stack
  • Both Box and Stack sprites will always be south-facing

data/scripts/

The primary effect on scripting is that a stackable item can be depicted as two completely different types of object on the map:

  • In the individual form, the object will have a .Type of whatever it's Name is defined as in materials.txt. It will use its own sprite.
  • In the stacked form, the object will have a .Type of either Stack or Box (see earlier to work out which applies) and the .Contents property of the stack will be the Name of whatever is in the stack.

A Stack or Box object is an individual item containing .Quantity (up to a MaxStackSize) of .Contents.

##See Also

⚠️ **GitHub.com Fallback** ⚠️