Container

Associated namespace: sm.container

A userdata object representing a container in the game.

Values:

Functions:

Operations:

OperationDescription
Container == ContainerChecks if two instances of Container refer to the same Container.

allowCollect boolean

Get:

Server only

Returns whether the container can collect items.

Set:

Server only

Sets whether the container can collect items.


allowSpend boolean

Get:

Server only

Returns whether the container can spend items.

Set:

Server only

Sets whether the container can spend items.


id integer

Get:

Returns the id of a container.


size integer

Get:

Returns the number of slots in a container.


canCollect(container, itemUuid, quantity)

Checks if sm.container.collect is allowed using the same parameters.

Parameters:

TypeNameDescription
ContainercontainerThe container.
UuiditemUuidThe uuid of the item.
integerquantityThe number of items.

Returns:

TypeDescription
booleanIndicates if the action is possible.

canSpend(container, itemUuid, quantity)

Checks if sm.container.spend is allowed.

Parameters:

TypeNameDescription
ContainercontainerThe container.
UuiditemUuidThe uuid of the item.
integerquantityThe number of items.

Returns:

TypeDescription
booleanIndicates if the action is possible.

getAllowCollect(container)

Server only

Returns whether the container can collect items.

Parameters:

TypeNameDescription
ContainercontainerThe container.

Returns:

TypeDescription
booleanReturns true if the container can collect.

getAllowSpend(container)

Server only

Returns whether the container can spend items.

Parameters:

TypeNameDescription
ContainercontainerThe container.

Returns:

TypeDescription
booleanReturns true if the container can spend.

getItem(container, slot)

Returns a table containing item uuid, quantity (and instance id for tools) at given slot.

Parameters:

TypeNameDescription
ContainercontainerThe container.
integerslotThe slot.

Returns:

TypeDescription
tableTable containg item {uuid = Uuid, instance = integer, quantity = integer}.

getMaxStackSize(container)

Returns the max stack size in the container.

Parameters:

TypeNameDescription
ContainercontainerThe container.

Returns:

TypeDescription
integerThe max stack size.

getSize(container)

Returns the number of slots in a container.

Parameters:

TypeNameDescription
ContainercontainerThe container.

Returns:

TypeDescription
integerThe size.

hasChanged(container, tick)

Server only

Returns true if the given tick is lower than the tick the container was last changed.

Parameters:

TypeNameDescription
ContainercontainerThe container.
integertickThe tick.

Returns:

TypeDescription
booleanReturns true if the container has been changed.

isEmpty(container)

Returns true if the container is empty.

Parameters:

TypeNameDescription
ContainercontainerThe container.

Returns:

TypeDescription
booleanReturns true if the container is empty.

setAllowCollect(container, allow)

Server only

Sets whether the container can collect items.

Parameters:

TypeNameDescription
ContainercontainerThe container.
booleanallowTrue if the container can collect.

setAllowSpend(container, allow)

Server only

Sets whether the container can spend items.

Parameters:

TypeNameDescription
ContainercontainerThe container.
booleanallowTrue if the container can spend.

setFilters(container, filter)

Server only

Set item filter.

Parameters:

TypeNameDescription
ContainercontainerThe container.
tablefilterA table of the item uuid's {Uuid, ...} allowed to be stored in the container.

setItem(container, slot, itemUuid, quantity, instance)

Server only

Sets the number of items stacked in a given container slot.

Parameters:

TypeNameDescription
ContainercontainerThe container.
integerslotThe slot.
UuiditemUuidThe uuid of the item.
integerquantityThe number of items.
integer=nilinstanceThe instance id, if the item is a tool. (Optional)

Returns:

TypeDescription
booleanIndicates if the action is possible.