Container
Represents a container
Values:
-
Get: (Server-Only) Returns whether the container can collect items.Set: (Server-Only) Sets whether the container can collect items.
-
Get: (Server-Only) Returns whether the container can spend items.Set: (Server-Only) Sets whether the container can spend items.
-
Get: Returns the id of a container.
-
Get: Returns the number of slots in a container.
Operations:
| Operation | Returns | Description |
|---|---|---|
Container == Container |
boolean | Checks if two instances of Container refer to the same Container. |
Server + Client
canCollect
container:canCollect( itemUuid, quantity )
Checks if sm.container.collect is allowed using the same parameters.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
itemUuid |
Uuid | The uuid of the item. |
quantity |
integer | The number of items. |
Returns:
| Type | Description |
|---|---|
| boolean | Indicates if the action is possible. |
canCollectAll
container:canCollectAll( uuids, quantities )
Checks if the container can collect a set of items.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
uuids |
table | The uuids of items to check. |
quantities |
table | The number of items of each uuid. Needs to match the number of uuids. |
Returns:
| Type | Description |
|---|---|
| boolean | Indicates if the action is possible. |
canSpend
container:canSpend( itemUuid, quantity )
Checks if sm.container.spend is allowed.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
itemUuid |
Uuid | The uuid of the item. |
quantity |
integer | The number of items. |
Returns:
| Type | Description |
|---|---|
| boolean | Indicates if the action is possible. |
getItem
container:getItem( slot )
Returns a table containing item uuid, quantity (and instance id for tools) at given slot.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
slot |
integer | The slot. |
Returns:
| Type | Description |
|---|---|
| table | Table containg item {uuid = Uuid, instance = integer, quantity = integer}. |
getMaxStackSize
container:getMaxStackSize( )
Returns the max stack size in the container.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
Returns:
| Type | Description |
|---|---|
| integer | The max stack size. |
getRevision
container:getRevision( )
Returns the network revision number of the container.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
Returns:
| Type | Description |
|---|---|
| number | The revision |
getSize
container:getSize( )
Returns the number of slots in a container.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
Returns:
| Type | Description |
|---|---|
| integer | The size. |
isEmpty
container:isEmpty( )
Returns true if the container is empty.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
Returns:
| Type | Description |
|---|---|
| boolean | Returns true if the container is empty. |
isFull
container:isFull( )
Returns true if all container slots in the container is at max capacity.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
Returns:
| Type | Description |
|---|---|
| boolean | Returns true if the container is empty. |
Server-only
bindOnTransaction
container:bindOnTransaction( callback, object )
Binds a container's onTransaction event to a custom callback. The event is triggered when a transaction is completed.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container instance. |
callback |
string | The name of the Lua function to bind. |
object (optional) |
table | The object that will receive the callback. (optional) |
clear
container:clear( )
Clears out the contents of the container.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
collect
container:collect( itemUuid, quantity, mustCollectAll )
Adds a quantity of a given item to a container.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
itemUuid |
Uuid | The uuid of the item. |
quantity |
integer | The number of items. |
mustCollectAll (optional) |
boolean | Must collect all items for the transaction to be valid. Defaults to true. (Optional) |
Returns:
| Type | Description |
|---|---|
| integer | The number of items successfully added. |
getAllowCollect
container:getAllowCollect( )
Returns whether the container can collect items.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
Returns:
| Type | Description |
|---|---|
| boolean | Returns true if the container can collect. |
getAllowSpend
container:getAllowSpend( )
Returns whether the container can spend items.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
Returns:
| Type | Description |
|---|---|
| boolean | Returns true if the container can spend. |
hasChanged
container:hasChanged( tick )
Returns true if the given tick is lower than the tick the container was last changed.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
tick |
integer | The tick. |
Returns:
| Type | Description |
|---|---|
| boolean | Returns true if the container has been changed. |
resize
container:resize( size, stackSize )
Resize a container.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container instance. |
size |
integer | The new size of the container. |
stackSize (optional) |
integer | The stack size. Defaults to maximum possible stack size(65535). |
setAllowCollect
container:setAllowCollect( allow )
Sets whether the container can collect items.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
allow |
boolean | True if the container can collect. |
setAllowSpend
container:setAllowSpend( allow )
Sets whether the container can spend items.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
allow |
boolean | True if the container can spend. |
setFilters
container:setFilters( filter )
Set item filter.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
filter |
table | A table of the item uuid's {Uuid, ...} allowed to be stored in the container. |
setItem
container:setItem( slot, itemUuid, quantity, instance )
Sets the number of items stacked in a given container slot.
Parameters:
| Name | Type | Description |
|---|---|---|
container |
Container | The container. |
slot |
integer | The slot. |
itemUuid |
Uuid | The uuid of the item. |
quantity |
integer | The number of items. |
instance (optional) |
integer | The instance id, if the item is a tool. (Optional) |
Returns:
| Type | Description |
|---|---|
| boolean | Indicates if the action is possible. |