This component allows your prefab to hold items given to it, show an interface to the player and all other related bells and whistles. There is also an inventory component, but that is very adapted to characters.

Component Container Fields

numbernumslotshow many stacks your container can store.
tablewidgetslotposhere you need to set the position (relative to the widget position) of the individual slots, using Vector3()
booleancanbeopenedtoggle the container locked.
booleanacceptsstacksaccept/deny several items per slot.
stringtypecan't open two of the same type the same time.
stringwidgetanimbank/widgetanimbuildset the visual background to the widget
Vector3()widgetposwhere (relative to the screens center) the widget is
numberside_align_tiprequired, unknown functionality
functionitemtestfnAnalyze the item, return true to let it in. Args: inst, item, slot
tablewidgetbuttoninfoThis is for an interactive button, like the crockpot has.
functiononopenfn/onclosefnFires at those events. Args: inst

Component Container Methods

IsFull/IsEmptynilbooleanwhether all/no slots contain items.
DropEverythingnilnilScatters the contents all around the prefab.
DestroyContentsnilnilconsume all items inside
GiveItemitem, slot, src_pos, drop_on_fail, skipsoundnilgive an item ('item' is the instance, not the name!)
GetItemInSlotslotinstreturns the instance stored
ClosenilnilShut it.
FindItemsfntable (contains instances)Iterate the container for items that result in "true" in "fn".
Hasname, amountboolean, amountamount is required.
ConsumeByNameitem, amountnilDestroys all items of that prefab until the amount in met.

Component Container Events

NameDataFires in/when...
dropitemitemDropEverything, DropItem
containergotitemitem, src_posGiveItem
itemgetslot, item, src_posGiveItem
itemloseslotRemoveItemBySlot, RemoveItem



Use the functions below to easily create the slotpos table.

slotSize is generally around 70, it determines the distance between slots.