Door

The game's doors. The server learns of a level door when a player's game first shows it, and then decides whether it is open and locked. Each dimension has its own state for each door, which is identified by the game's entity GUID. A script can also hang a new door with Door.spawn, using a leaf from Door.models, which players in its dimension use like the level's. door.toJSON() gives a hung door's definition, locked as it is now, or null for a level door.

door.linkedTo()

Door.linkedTo(areaId)

Doors linked to an area through the level's crime_door data, as { guid, name, position, link }, with `link` being 'entrance', 'basic' or 'storage'. It works with no players nearby, so a listed door may have no Door object yet, and Door.find(guid) returns one after a client has shown it. An unknown or unconnected area gives an empty list.

door.all()

Door.all()

All doors the server knows so far.

door.getById()

Door.getById(id)

The door with this network id, or null.

door.find()

Door.find(guid, dimension = GLOBAL_WORLD)

The door with this GUID, up to 16 hex digits, with or without 0x. Null if no player's game has shown it yet, or it is removed from that dimension.

door.remove()

Door.remove(guid, dimension = GLOBAL_WORLD)

Removes a level door and its collision from one dimension, as a level edit on clients there. Players in the global dimension can see all others, so it disappears for them too, and removing it from the global dimension removes it everywhere. A removed door cannot be used there, and all and find skip it. Door.restore reverses this. It is not saved, ending when the server restarts or its resource stops. Throws a TypeError if no client has reported the GUID yet, since the server learns level doors from clients.

door.restore()

Door.restore(guid, dimension = GLOBAL_WORLD)

Reverses a door's removal from a dimension, whether by a script, a world export or another level edit, returning it in its original form. A removal from the global dimension can be reversed only there. Returns the door, or null if that dimension has no such removal.

door.removed()

Door.removed(dimension)

Doors removed from a dimension by scripts or world exports, each { guid, name, position, dimension }, in no particular order.

door.closestTo()

Door.closestTo(player)

Asks a player's game which door they are at, and resolves to { found, reason, door }.

door.spawn()

Door.spawn(definition, dimension = GLOBAL_WORLD)

Adds a new door that players in the dimension can open, close, unlock and pick, with the same server checks as level doors. It starts closed, and later joiners get it. The server generates the GUID, 6b636473 plus a number, which stays the same on all clients until the server stops. It is not saved, so add it again at startup using door.toJSON(), and it is removed when the resource that created it stops. NPCs cannot walk through it, since the level's navigation data does not include it. Throws a TypeError for an unknown model, a non-finite position or rotation, a position over 16384 from the origin, an invalid lock type, a key with no item class, or a name over 64 bytes, and a RangeError for a lockLevel outside 0 to 1.

door.models()

Door.models()

Door meshes used in the game's levels, which Door.spawn accepts, sorted by path. Each is { path, name, hinge, placements }: the file path, objects/characters/assets/doors/...cdf, the file name with no extension, the hinge side, 'left' or 'right', and how many level doors use it.

door.key

key

The key working this door now, as an item class id: its own from setKey, then its area's from area.lockKey, then the level's from lockKey, or '' if none.

door.setKey()

setKey(item)

Gives this door its own key, ahead of its area's, such as a supervisor's key for one room. null removes it. Throws a TypeError for an item class that does not exist.

door.areas

areas

Level areas linked to this door through crime_door data, such as its house, workshop or storeroom. Doors created by scripts have none.

door.position

position

Its location.

door.open

open

Whether the door is open.

door.side

side

The side it was last opened from.

door.locked

locked

Whether the door is locked. You can assign true or false. Players cannot unlock or pick a lock a script set.

door.lockedByScript

lockedByScript

Whether a script set its lock.

door.lockLevel

lockLevel

How hard the lock is to pick, from 0, easy, to 1, hard, whether the level's or set by a script for all players in the dimension, including later arrivals. The game's lock-picking minigame uses it. Assign 0 to 1 to set it, or null to restore the level's.

door.setOpen()

setOpen(open, side)

Opens or closes it with nobody pushing, and opening also unlocks it. Returns false if it is already in that state.

door.spawned

spawned

True for a door from Door.spawn, false for a level door.

door.model

model

The mesh path as in Door.models(), objects/characters/assets/doors/...cdf. For a level door, it is the path from the client that showed it.

door.destroy()

destroy()

Removes the door. A door from Door.spawn goes for good on all clients. A level door goes from its own dimension, as with Door.remove(door.guid, door.dimension), and Door.restore returns it.

door.guid

guid

The game's entity GUID, sixteen lower-case hex digits.

door.name

name

The door's entity name in the level, or ''.

door.dimension

dimension

The dimension whose state of the door this object is.

door.lockKey

lockKey

The item class of the key that opens it, or '' if none does.

door.canBePicked

canBePicked

Whether a player can pick its lock.

door.builtLocked

builtLocked

Whether the level built it locked.