Stash
Defined in: server/api.d.ts:6588
Container handle for a spawned chest, a level chest, or virtual stock without a world entity.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Stash(
id):Stash
Defined in: server/api.d.ts:6593
Creates a script wrapper for an existing container with this ID; use Stash.spawn() for a chest, Stash.createVirtual() for stock without a chest, or Stash.find() for one the level places.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Stash
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”addItem()
Section titled “addItem()”addItem(
request):InventoryResult
Defined in: server/api.d.ts:6691
Puts items in the container, as Inventory.add gives them to a player.
Parameters
Section titled “Parameters”request
Section titled “request”amount
Section titled “amount”number
string
metadata?
Section titled “metadata?”Record<string, unknown>
revision?
Section titled “revision?”number
Returns
Section titled “Returns”destroy()
Section titled “destroy()”destroy():
void
Defined in: server/api.d.ts:6674
Destroys this scripted chest or virtual stash and forgets what was in it. Anything inside goes with it. Does nothing to a container the level places.
Returns
Section titled “Returns”void
getInventory()
Section titled “getInventory()”getInventory(): {
items:InventoryRow[];revision:number; } |null
Defined in: server/api.d.ts:6686
Reads what the container holds. A linked child reads its master’s.
Returns
Section titled “Returns”{ items: InventoryRow[]; revision: number; } | null
A copy of its rows, or null once the container is gone.
open()
Section titled “open()”open(
player):boolean
Defined in: server/api.d.ts:6680
Opens a virtual stash from anywhere in its virtual world. Calls stashInteract before granting exclusive access. Returns false for a physical stash, a locked or busy stash, an unavailable player, or a script refusal. A true result requests the screen; the client releases access if it cannot open.
Parameters
Section titled “Parameters”player
Section titled “player”Player whose native transfer screen should open.
Returns
Section titled “Returns”boolean
removeItem()
Section titled “removeItem()”removeItem(
request):InventoryResult
Defined in: server/api.d.ts:6696
Takes exact units out of named rows, every one of them or none.
Parameters
Section titled “Parameters”request
Section titled “request”revision?
Section titled “revision?”number
Returns
Section titled “Returns”setInventory()
Section titled “setInventory()”setInventory(
request):InventoryResult
Defined in: server/api.d.ts:6701
Replaces everything in the container, which is how saved contents come back. At most 128 rows. An empty list empties it.
Parameters
Section titled “Parameters”request
Section titled “request”object[]
revision?
Section titled “revision?”number
Returns
Section titled “Returns”setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: server/api.d.ts:8797
Moves this entity into another virtual world.
Parameters
Section titled “Parameters”number
Virtual-world identifier used to partition replication and visibility.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: server/api.d.ts:8803
Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:6669
Formats this container handle for logging and debugging.
Returns
Section titled “Returns”string
The stash ID, its level GUID, how much is in it, who has it open and whether it is locked.
Inherited from
Section titled “Inherited from”
staticall():Stash[]
Defined in: server/api.d.ts:6722
Lists every container the server currently has: every one the level places, which exist from boot in the global world, and every scripted chest or virtual stash. In another virtual world a level container is built the first time anything there reaches it, so this lists only those.
Returns
Section titled “Returns”Stash[]
One handle per live container, in no particular order.
createVirtual()
Section titled “createVirtual()”
staticcreateVirtual(virtualWorld?):Stash
Defined in: server/api.d.ts:6707
Creates empty server-owned stock without spawning a chest on any client. Supports the same inventory methods and events as physical stashes. Use open(player) to show the native transfer screen, and destroy() to discard it. Contents last until destroyed or the server restarts.
Parameters
Section titled “Parameters”virtualWorld?
Section titled “virtualWorld?”number
World whose players may open it, as a uint32 number; defaults to the global world. Invalid values throw before creating stock.
Returns
Section titled “Returns”Stash
destroyAll()
Section titled “destroyAll()”
staticdestroyAll(virtualWorld?):number
Defined in: server/api.d.ts:6753
Destroys scripted chests and virtual stashes, including everything inside. The level’s own stay.
Parameters
Section titled “Parameters”virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world to clear; omitted clears every one of them.
Returns
Section titled “Returns”number
How many containers were removed.
find()
Section titled “find()”
staticfind(guid,virtualWorld?):Stash|null
Defined in: server/api.d.ts:6737
Looks a container up by its EntityGuid: one the level places, by the level’s own identity for it, which survives a restart and is the same on every machine, and is found in any virtual world; or one a script spawned, in the virtual world it was spawned in, for as long as it exists.
Parameters
Section titled “Parameters”string
The container’s EntityGuid as hex, with or without an 0x prefix, as stash.guid prints it.
virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world to look in; omitted looks in the global one, where every body starts.
Returns
Section titled “Returns”Stash | null
The container’s handle, or null when no container has that GUID there.
getById()
Section titled “getById()”
staticgetById(id):Stash|null
Defined in: server/api.d.ts:6729
Looks a container up by its network entity ID.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Stash | null
The container’s handle, or null when no live container has that ID.
nearest()
Section titled “nearest()”
staticnearest(position,maxDistance?,virtualWorld?):Stash|null
Defined in: server/api.d.ts:6746
Finds the physical container nearest a point, level or spawned. Virtual stock is excluded. The server knows where every container the level places stands, so this answers at once, without asking a client.
Parameters
Section titled “Parameters”position
Section titled “position”The point to measure from, usually a player’s position.
maxDistance?
Section titled “maxDistance?”number
How far to look, in metres; omitted looks 5 m, about the reach the game gives a chest.
virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world to look in; omitted looks in the global one.
Returns
Section titled “Returns”Stash | null
The nearest container’s handle, or null when none is that close.
spawn()
Section titled “spawn()”
staticspawn(position?,rotation?,virtualWorld?):Stash
Defined in: server/api.d.ts:6716
Spawns and replicates an empty container. Fill it with addItem or setInventory, or let players put things in it.
Parameters
Section titled “Parameters”position?
Section titled “position?”Optional world-space spawn position; omitted components default to zero.
rotation?
Section titled “rotation?”Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in degrees.
virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world the container belongs to; omitted puts it in the global one.
Returns
Section titled “Returns”Stash
The newly spawned container handle.
Properties
Section titled “Properties”
readonlyguid:string
Defined in: server/api.d.ts:6603
The EntityGuid every client finds this container under, as sixteen lowercase hex digits: the level’s own for a container the level places, the one minted when a script spawned it otherwise. Empty for virtual stock; Stash.find takes physical container GUIDs back.
holderId
Section titled “holderId”
readonlyholderId:number
Defined in: server/api.d.ts:6633
The network ID of the player who has its contents open, or 0. While it is held, every other player’s open is refused before their transfer screen appears.
readonlyid:number
Defined in: server/api.d.ts:8765
Immutable network entity identifier.
Inherited from
Section titled “Inherited from”isOpen
Section titled “isOpen”
readonlyisOpen:boolean
Defined in: server/api.d.ts:6623
Whether a player holds its view. Physical chests animate their lid by it; virtual stashes have no lid.
isVirtual
Section titled “isVirtual”
readonlyisVirtual:boolean
Defined in: server/api.d.ts:6628
Whether this stash has stock without a chest entity. Open it with open(player); its position and rotation do not govern access, and guid is empty.
itemCount
Section titled “itemCount”
readonlyitemCount:number
Defined in: server/api.d.ts:6618
How many rows the server is holding. A container linked to another in the level opens that one’s contents, and reads them here too.
keyItem
Section titled “keyItem”keyItem:
string
Defined in: server/api.d.ts:6653
The item class GUID of the key that unlocks the container, as player.giveItem takes it. Reads the level’s own key until a script assigns one; empty when it has none. Assigning a class makes every client ask for that class instead, so a player holding it is offered “unlock and open”; assigning an empty string restores the level’s. An unknown class is refused and logged. The server does not see inventories: which key a player holds is their client’s to say, and stashInteract is where a script checks its own record.
levelGuid
Section titled “levelGuid”
readonlylevelGuid:string
Defined in: server/api.d.ts:6608
The level’s own EntityGuid for a container the level places, as sixteen lowercase hex digits; empty for a scripted chest or virtual stock. The same on every machine, so it is the identity to store a container under; Stash.find takes it back.
locked
Section titled “locked”locked:
boolean
Defined in: server/api.d.ts:6638
Whether the container is locked. Assignment reaches every client that has it streamed in. A locked container offers only its key and its lockpick; a script locking one marks it lockedByServer, which the generated home or shop key does not open. Unlocking it by any route the server accepted clears both.
lockedByServer
Section titled “lockedByServer”
readonlylockedByServer:boolean
Defined in: server/api.d.ts:6643
Whether the lock was set by a script rather than by the level. The generated home or shop key does not open a container locked from here.
lockpickable
Section titled “lockpickable”lockpickable:
boolean
Defined in: server/api.d.ts:6648
Whether the container offers the lockpick while locked. Starts as the level authored it; assignment reaches every client, and a pick on one that cannot be is refused.
readonlyname:string
Defined in: server/api.d.ts:6613
The entity name the level gives the container, or spawned_stash_<stashId> for a scripted chest; empty for virtual stock.
position
Section titled “position”position:
Vector3
Defined in: server/api.d.ts:8775
Authoritative world-space position; assignment forces replicated state.
Inherited from
Section titled “Inherited from”rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: server/api.d.ts:8780
Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.
Inherited from
Section titled “Inherited from”startsLocked
Section titled “startsLocked”
readonlystartsLocked:boolean
Defined in: server/api.d.ts:6663
Whether the level builds this container locked, which is the state it has at boot. False for one a script spawned.
stashId
Section titled “stashId”
readonlystashId:number
Defined in: server/api.d.ts:6598
The server-minted identity of a scripted chest or virtual stash, from 1. Distinct from the network entity id. Virtual stashes use it for an inventory GUID without creating a chest. 0 for a level chest.
readonlystate:StateBag
Defined in: server/api.d.ts:8785
Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.
Inherited from
Section titled “Inherited from”useDirection
Section titled “useDirection”
readonlyuseDirection:Vector3
Defined in: server/api.d.ts:6658
The horizontal unit direction a player has to face the container along to be offered it: the game’s own use check only offers a chest to a body standing behind this axis and looking along it. Stand at position - useDirection * distance to face it.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: server/api.d.ts:8770
Current virtual-world identifier.