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:
- [
Box](Box (Consumable)) - used for Statics and Utilities- A
Boxwill also be used for anything that does not define aStackSprite
- A
- [
Stack](Stack (Consumable)) - used for Consumables
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:
-
Boxstacks 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.Openedwhich changes the sprite used for the box; but the label will remain -
Stackstacks will use theStackSpriteassociated with their contents:- The piece of the sprite shown depends on the quantity of items in the stack
- Both
BoxandStacksprites will always be south-facing
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
.Typeof whatever it'sNameis defined as inmaterials.txt. It will use its own sprite. - In the stacked form, the object will have a
.Typeof eitherStackorBox(see earlier to work out which applies) and the.Contentsproperty of the stack will be theNameof whatever is in the stack.
A Stack or Box object is an individual item containing .Quantity (up to a MaxStackSize) of .Contents.
##See Also
-
data/materials.txt:AutoOrderAutoOrderQuantity-
PropertiesMobileObject -
PropertiesRubbish -
PropertiesSellable -
PropertiesShelfObject -
PropertiesSlowDelivery -
PropertiesUncloneable Sprite - objects.png- [
Sprite - sprites.png](Sprite (sprites.png)) StackSpriteTeleportable
-
Consumables:
- [
Stack](Stack (Consumable)) - [
Box](Box (Consumable))
- [
-
data/scripts/:-
.Carried- numeric, not boolean! .CarrierId.Carrying-
.Contents- object type of items in a stack .Hidden.LastAccess.Opened.Quantity.SubType-
.Type- object type of individual items
-