Stash

A container held by the server. It can be a chest in the world, which players in view see as the game's container and open with the use key, a storage with no world object that only scripts open, such as a bank, or the searchable body of a knocked-out player or dead NPC. Only the player who opened it receives its contents.

stash.spawn()

Stash.spawn(position = {}, orientation = {}, dimension = GLOBAL_WORLD, options = {})

Places a chest, or any other mesh as a container. All clients in view build it and offer the game's Search. Throws a TypeError for options that are not an object, or a model that is not a .cgf, .cga or .cdf path.

stash.all()

Stash.all()

All stashes.

stash.getById()

Stash.getById(id)

The stash with this network id, or null.

stash.createStorage()

Stash.createStorage(dimension = GLOBAL_WORLD)

Creates a storage with no world object, which scripts open for players.

stash.find()

Stash.find(guid, dimension = GLOBAL_WORLD)

A chest by GUID, or an adopted level chest by level GUID, in its dimension, or null.

stash.levelChests()

Stash.levelChests(position, radius = LEVEL_CHEST_RADIUS)

The sacks, barrels, wardrobes and chests the server's level places, within `radius` metres of a position, or all of them with no position. Each is { placedGuid, position, model, lockedAtBoot, canBePicked, lockLevel }, where lockLevel is the level's, 0 to 1, or null where the game makes one up on reset. They belong to the game, with each player's game filling them as the level says, until Stash.adopt hands one to the server.

stash.adopt()

Stash.adopt(placedGuid, dimension = GLOBAL_WORLD)

Hands a level chest to the server. It then holds what the server gives it, starting empty and dropping what the game put in. It keeps the level's lock until a script changes locked, canBePicked or keyClass, and all players open it as a server chest, with stashInteract and the server's lock and key. destroy() returns it to the game, which keeps the lock and what it last showed. Adopting the same chest again in that dimension gives the same Stash. Null if the server's level has no chest with that GUID.

stash.nearest()

Stash.nearest(position, maxDistance = REACH, dimension = GLOBAL_WORLD)

The nearest chest within maxDistance, skipping storages, or null.

stash.destroyAll()

Stash.destroyAll(dimension)

Removes all stashes, or those in one dimension, and returns how many. Bodies of players and NPCs stay.

stash.guid

guid

Its GUID, sixteen hex digits, or '' for a storage.

stash.placedGuid

placedGuid

An adopted level chest's level GUID, sixteen hex digits as from Stash.levelChests, or '' for any other container.

stash.name

name

'spawned_stash_<number>' for a chest a script placed, 'level_chest_<placedGuid>' for an adopted level chest, or '' for a storage.

stash.isStorage

isStorage

Whether it is a storage with no chest.

stash.locked

locked

Whether it is locked, which stops it opening. Unlocking in the game with a key or lockpick fires stashUnlocked. You can assign to it.

stash.serverLocked

serverLocked

Whether a script locked it.

stash.canBePicked

canBePicked

Whether players can pick its lock. You can assign to it.

stash.keyClass

keyClass

Which key item class fits its lock, by GUID, or '' if no key does. You can assign to it.

stash.lockLevel

lockLevel

How hard the lock is to pick, from 0, easy, to 1, hard, as set by a script for all players. Null means the game's value, either an adopted chest's level value or one the game makes up. Assign 0 to 1, or null.

stash.lockStyle

lockStyle

The lock the game's minigame shows, 'common' or 'fancy', as set by a script for all players, or null for the level's. Assign 'common', 'fancy' or null, and anything else throws a RangeError.

stash.model

model

The model from Stash.spawn's options.model. Empty for the default chest and for level chests, whose models Stash.levelChests lists.

stash.lockedAtBoot

lockedAtBoot

Whether the level locks it, for an adopted level chest built locked. A chest placed by a script is never built locked.

stash.isOpen

isOpen

Whether a player has it open.

stash.heldById

heldById

The id of the player with it open, or 0.

stash.itemCount

itemCount

The number of item rows it holds.

stash.position

position

Its location.

stash.rotation

rotation

Its rotation.

stash.body

body

For a searchable body, the player it belongs to, otherwise null.

stash.getInventory()

getInventory()

Its contents as { revision, items }, or null.

stash.addItem()

addItem(request)

Adds items.

stash.removeItem()

removeItem(request)

Takes items out.

stash.setInventory()

setInventory(request)

Replaces all contents.

stash.open()

open(player)

Opens the stash for a player, returning false if it cannot open.

stash.destroy()

destroy()

Removes the stash, firing stashDestroy, and closes it for a player with it open.

stash.id

id: number

The network id.

stash.dimension

dimension: number

Its dimension.