Door
Defined in: server/api.d.ts:6122
Replicated handle for a door: one of the level’s own, or one a script or a world resource hung with Door.spawn.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Door(
id):Door
Defined in: server/api.d.ts:6127
Creates a script wrapper for a door the server already knows; use Door.spawn to hang a new one, or Door.find for one the level places.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Door
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy():
void
Defined in: server/api.d.ts:6216
Takes the door out. A door a script or a world resource hung is taken down for good. A door the level places is taken out of this handle’s virtual world, collision and all, through a level edit that every client seeing that world applies – a player in the global world sees every world, so it is hidden for them too; the copy in the global world takes it out of every world. Door.restore puts a level door back, and Door.removed lists the ones that are out. Kept in memory only, like every level edit: a removal is undone when the server restarts or the resource that made it stops.
Returns
Section titled “Returns”void
setOpen()
Section titled “setOpen()”setOpen(
open,fromFront?):boolean
Defined in: server/api.d.ts:6211
Opens or closes the door with nobody pushing it. Every client that has the door built plays the game’s own swing; one arriving later finds it posed the same way. Opening a locked door unlocks it, as the game’s own Open does.
Parameters
Section titled “Parameters”boolean
True to open the door, false to close it.
fromFront?
Section titled “fromFront?”boolean
Which side the leaf is worked from, and so which way it swings. Omitted keeps the side it was last worked from.
Returns
Section titled “Returns”boolean
False when the door is already that way.
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: server/api.d.ts:9890
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:9896
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”toJSON()
Section titled “toJSON()”toJSON():
DoorDefinition|null
Defined in: server/api.d.ts:6222
The definition Door.spawn takes to hang this door again, with whether it is locked now: what a script saves. The server keeps nothing past a restart. It is one entry of a World Builder map’s doors array.
Returns
Section titled “Returns”DoorDefinition | null
Null for a door the level places.
toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:6203
Formats this door handle for logging and debugging.
Returns
Section titled “Returns”string
The door ID, its level GUID and whether it is open and locked.
Inherited from
Section titled “Inherited from”
staticall():Door[]
Defined in: server/api.d.ts:6228
Lists every door: the level’s own, all of which exist from boot in the global world, and every door a script or a world resource hung. In another virtual world a level door is built the first time anything there reaches it, so this lists only those. A level door taken out of a world is not listed for it; Door.removed lists those.
Returns
Section titled “Returns”Door[]
One handle per known door, in no particular order.
find()
Section titled “find()”
staticfind(guid,virtualWorld?):Door|null
Defined in: server/api.d.ts:6280
Looks a door up by the level’s own identity for it, which survives a restart and is the same on every machine. A door the level places is found in any virtual world it has not been taken out of. A door a script hung is found by door.guid in the world it hangs in.
Parameters
Section titled “Parameters”string
The door’s level EntityGuid as hex, with or without an 0x prefix, as door.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”Door | null
The door’s handle, or null when there is no such door there.
getById()
Section titled “getById()”
staticgetById(id):Door|null
Defined in: server/api.d.ts:6272
Looks a door up by its network entity ID.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Door | null
The door’s handle, or null when no live door has that ID.
getForArea()
Section titled “getForArea()”
staticgetForArea(areaId):AreaDoor[]
Defined in: server/api.d.ts:6287
Lists the doors the level links to an area as its crime_doors, with their GUID, name, position and link type, straight from the level catalog – so a door that no client has reported yet is listed too. Pass a guid to Door.find for the live handle and its locked state. Only native links: a script area has none.
Parameters
Section titled “Parameters”areaId
Section titled “areaId”string
The area’s id, as area.id prints it.
Returns
Section titled “Returns”AreaDoor[]
The doors; empty for an unknown area or one with no links.
models()
Section titled “models()”
staticmodels():DoorModelInfo[]
Defined in: server/api.d.ts:6242
Lists every leaf mesh the shipped levels hang doors from, which is every model Door.spawn takes.
Returns
Section titled “Returns”One row per mesh, sorted by path.
queryNearest()
Section titled “queryNearest()”
staticqueryNearest(player):Promise<NearestDoor>
Defined in: server/api.d.ts:6296
Asks a player’s client which door their body is standing at. The server knows every door the level places but has no world to measure distances in, so this is how a command finds the door in front of a player, and the answer is what that client sees now rather than what the replica last carried.
The promise always settles: on the answer, on a five-second timeout, or when the player leaves, with found false and reason saying which.
Parameters
Section titled “Parameters”player
Section titled “player”The player to ask. The question goes to their own client.
Returns
Section titled “Returns”Promise<NearestDoor>
The answer, once that client has given one.
remove()
Section titled “remove()”
staticremove(guid,virtualWorld?):void
Defined in: server/api.d.ts:6250
Takes a door the level places out of a virtual world, collision and all, as door.destroy() does, without needing its handle. Taking out a door that is already out of that world, or of the global one, does nothing; taking out one that has a level edit in that world, a move or a swap, replaces that edit.
Parameters
Section titled “Parameters”string
The level door’s EntityGuid as hex, as door.guid prints it.
virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world to take it out of; the global one, and so every world, when omitted.
Returns
Section titled “Returns”void
Throws for a GUID that is not one of the level’s doors.
removed()
Section titled “removed()”
staticremoved(virtualWorld?):RemovedDoor[]
Defined in: server/api.d.ts:6265
Lists the doors the level places that are taken out of a virtual world, by a script or a World Builder export alike.
Parameters
Section titled “Parameters”virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world to list; omitted lists every one of them.
Returns
Section titled “Returns”One row per removal, in no particular order.
restore()
Section titled “restore()”
staticrestore(guid,virtualWorld?):Door|null
Defined in: server/api.d.ts:6258
Puts back a level door that a script, a world resource or any other level edit took out of a virtual world. It comes back closed, and locked as the level builds it.
Parameters
Section titled “Parameters”string
The level door’s EntityGuid as hex, as Door.removed lists it.
virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world to put it back in; the global one when omitted. A door taken out of the global world is only put back from there.
Returns
Section titled “Returns”Door | null
The door, or null when that world had no such removal.
spawn()
Section titled “spawn()”
staticspawn(definition,virtualWorld?):Door
Defined in: server/api.d.ts:6236
Hangs a working door where the level has none: every player in the virtual world sees it, opens and closes it, keys or picks its lock, and the server judges every use by the same rules as the level’s own doors. It starts closed. Kept in memory only: hang it again on boot. The resource that hangs it owns it, so it goes when that resource stops. NPCs do not path through it: the level’s navigation mesh has no link for it.
Parameters
Section titled “Parameters”definition
Section titled “definition”The leaf, where it hangs and how it locks, in the format of one entry of a World Builder map’s doors array.
virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world whose players see it; the global one when omitted.
Returns
Section titled “Returns”Door
The door. Throws for an unknown model, a transform that is not finite, a lock name that is not one of the four, or a key that is not an item class.
Properties
Section titled “Properties”
readonlyareas:Area[]
Defined in: server/api.d.ts:6182
The level areas that link this door as one of their crime_doors – the house, workshop or storage room it belongs to, as the level itself records it. Nothing is inferred from where the door stands.
readonlyguid:string
Defined in: server/api.d.ts:6132
The door’s EntityGuid, as sixteen lowercase hex digits, the same on every machine; Door.find takes it back. A level door’s never changes, so it is the identity to store one under. A hung door’s lasts only until the server stops: store its toJSON() instead.
readonlyid:number
Defined in: server/api.d.ts:9858
Immutable network entity identifier.
Inherited from
Section titled “Inherited from”keyItem
Section titled “keyItem”
readonlykeyItem:string
Defined in: server/api.d.ts:6172
The item class GUID of the key the level assigns to the door’s keyhole, as player.giveItem takes it. Empty when it takes none of its own – most doors open to the generated home or shop key instead. The server does not see inventories, so this is for a resource that keeps its own.
locked
Section titled “locked”locked:
boolean
Defined in: server/api.d.ts:6152
Whether the door is locked. Assignment reaches every client that has the door streamed in, including one already standing at it. A door locked from here can only be opened again from here or with a lockpick: a player unlocking it by hand or with a key is refused.
lockedByServer
Section titled “lockedByServer”
readonlylockedByServer:boolean
Defined in: server/api.d.ts:6157
Whether the lock was set by a script or an operator rather than by the level. It clears when the door is unlocked, by any route the server accepted.
lockpickable
Section titled “lockpickable”
readonlylockpickable:boolean
Defined in: server/api.d.ts:6177
Whether the level lets this door be lockpicked. A lockpick reported on one that cannot be is refused.
readonlymodel:string
Defined in: server/api.d.ts:6197
The leaf mesh the door hangs, as Door.models() lists it: objects/characters/assets/doors/...cdf.
readonlyname:string
Defined in: server/api.d.ts:6167
The entity name the level gives the door; for a hung door, the name it was hung with, or spawned_door_<n> without one.
readonlyopen:boolean
Defined in: server/api.d.ts:6142
Whether the door is standing open. Change it with setOpen, which also says which way it swings.
openedFromFront
Section titled “openedFromFront”
readonlyopenedFromFront:boolean
Defined in: server/api.d.ts:6147
Which side the leaf was last worked from, which decides the way it swings. A player arriving later poses the door from this, so everyone sees it swung the same way.
position
Section titled “position”position:
Vector3
Defined in: server/api.d.ts:9868
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:9873
Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.
Inherited from
Section titled “Inherited from”spawned
Section titled “spawned”
readonlyspawned:boolean
Defined in: server/api.d.ts:6192
Whether a script or a world resource hung this door with Door.spawn, rather than the level placing it.
startsLocked
Section titled “startsLocked”
readonlystartsLocked:boolean
Defined in: server/api.d.ts:6187
Whether the level builds this door locked, which is the state it has at boot; for a hung door, whether it was hung locked.
readonlystate:StateBag
Defined in: server/api.d.ts:9878
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”stateToken
Section titled “stateToken”
readonlystateToken:number
Defined in: server/api.d.ts:6137
Bumped on every durable change. Clients act on the edges rather than the value, so it only tells one change from the next.
usable
Section titled “usable”usable:
boolean
Defined in: server/api.d.ts:6162
Whether players may work the door. False hides its prompt to open, close, unlock or pick it, and a player’s use is refused on their own machine before the door or the body moves – no round trip, no swing back. A report against it is refused here too, for a client that did not. Assignment reaches every client that has the door streamed in, including one already standing at it. The door stays as it is: setOpen and locked still work, and NPCs still pass it. Per door, not per player: refuse one player with a client doorInteract handler.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: server/api.d.ts:9863
Current virtual-world identifier.