Container
Associated namespace: sm.container
A userdata object representing a container in the game.
Values:
Functions:
- canCollect
- canSpend
- getAllowCollect
- getAllowSpend
- getItem
- getMaxStackSize
- getSize
- hasChanged
- isEmpty
- setAllowCollect
- setAllowSpend
- setFilters
- setItem
Operations:
Operation | Description |
---|---|
Container == Container | Checks 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:
Type | Name | Description |
---|---|---|
Container | container | The container. |
Uuid | itemUuid | The uuid of the item. |
integer | quantity | The number of items. |
Returns:
Type | Description |
---|---|
boolean | Indicates if the action is possible. |
canSpend(container, itemUuid, quantity)
Checks if sm.container.spend is allowed.
Parameters:
Type | Name | Description |
---|---|---|
Container | container | The container. |
Uuid | itemUuid | The uuid of the item. |
integer | quantity | The number of items. |
Returns:
Type | Description |
---|---|
boolean | Indicates if the action is possible. |
getAllowCollect(container)
Server only
Returns whether the container can collect items.
Parameters:
Type | Name | Description |
---|---|---|
Container | container | The container. |
Returns:
Type | Description |
---|---|
boolean | Returns true if the container can collect. |
getAllowSpend(container)
Server only
Returns whether the container can spend items.
Parameters:
Type | Name | Description |
---|---|---|
Container | container | The container. |
Returns:
Type | Description |
---|---|
boolean | Returns 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:
Type | Name | Description |
---|---|---|
Container | container | The container. |
integer | slot | The slot. |
Returns:
Type | Description |
---|---|
table | Table containg item {uuid = Uuid, instance = integer, quantity = integer}. |
getMaxStackSize(container)
Returns the max stack size in the container.
Parameters:
Type | Name | Description |
---|---|---|
Container | container | The container. |
Returns:
Type | Description |
---|---|
integer | The max stack size. |
getSize(container)
Returns the number of slots in a container.
Parameters:
Type | Name | Description |
---|---|---|
Container | container | The container. |
Returns:
Type | Description |
---|---|
integer | The size. |
hasChanged(container, tick)
Server only
Returns true if the given tick is lower than the tick the container was last changed.
Parameters:
Type | Name | Description |
---|---|---|
Container | container | The container. |
integer | tick | The tick. |
Returns:
Type | Description |
---|---|
boolean | Returns true if the container has been changed. |
isEmpty(container)
Returns true if the container is empty.
Parameters:
Type | Name | Description |
---|---|---|
Container | container | The container. |
Returns:
Type | Description |
---|---|
boolean | Returns true if the container is empty. |
setAllowCollect(container, allow)
Server only
Sets whether the container can collect items.
Parameters:
Type | Name | Description |
---|---|---|
Container | container | The container. |
boolean | allow | True if the container can collect. |
setAllowSpend(container, allow)
Server only
Sets whether the container can spend items.
Parameters:
Type | Name | Description |
---|---|---|
Container | container | The container. |
boolean | allow | True if the container can spend. |
setFilters(container, filter)
Server only
Set item filter.
Parameters:
Type | Name | Description |
---|---|---|
Container | container | The container. |
table | filter | A 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:
Type | Name | Description |
---|---|---|
Container | container | The container. |
integer | slot | The slot. |
Uuid | itemUuid | The uuid of the item. |
integer | quantity | The number of items. |
integer=nil | instance | The instance id, if the item is a tool. (Optional) |
Returns:
Type | Description |
---|---|
boolean | Indicates if the action is possible. |