Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Runtime classServer APIGenerated

Door

Defined in: server/api.d.ts:5554

Replicated handle for one of the level’s own doors.

new Door(id): Door

Defined in: server/api.d.ts:5559

Creates a script wrapper for a door the server already knows; doors are the level’s own and are never spawned.

number

Network entity identifier.

Door

Entity.constructor

setOpen(open, fromFront?): boolean

Defined in: server/api.d.ts:5628

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.

boolean

True to open the door, false to close it.

boolean

Which side the leaf is worked from, and so which way it swings. Omitted keeps the side it was last worked from.

boolean

False when the door is already that way.


setVirtualWorld(world): void

Defined in: server/api.d.ts:8797

Moves this entity into another virtual world.

number

Virtual-world identifier used to partition replication and visibility.

void

Entity.setVirtualWorld


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.

Entity | null

Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.

void

Entity.setVisibleTo


toString(): string

Defined in: server/api.d.ts:5620

Formats this door handle for logging and debugging.

string

The door ID, its level GUID and whether it is open and locked.

Entity.toString


static all(): Door[]

Defined in: server/api.d.ts:5634

Lists every door the level places, all of which exist from boot in the global world. In another virtual world a door is built the first time anything there reaches it, so this lists only those.

Door[]

One handle per known door, in no particular order.


static find(guid, virtualWorld?): Door | null

Defined in: server/api.d.ts:5649

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 always found, in any virtual world.

string

The door’s level EntityGuid as hex, with or without an 0x prefix, as door.guid prints it.

number

Optional virtual world to look in; omitted looks in the global one, where every body starts.

Door | null

The door’s handle, or null when the level places no such door.


static getById(id): Door | null

Defined in: server/api.d.ts:5641

Looks a door up by its network entity ID.

number

Network entity identifier.

Door | null

The door’s handle, or null when no live door has that ID.


static getForArea(areaId): AreaDoor[]

Defined in: server/api.d.ts:5656

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.

string

The area’s id, as area.id prints it.

AreaDoor[]

The doors; empty for an unknown area or one with no links.


static queryNearest(player): Promise<NearestDoor>

Defined in: server/api.d.ts:5665

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.

Player

The player to ask. The question goes to their own client.

Promise<NearestDoor>

The answer, once that client has given one.

readonly areas: Area[]

Defined in: server/api.d.ts:5609

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.


readonly guid: string

Defined in: server/api.d.ts:5564

The level’s own EntityGuid, as sixteen lowercase hex digits. The same on every machine, so it is the identity to store a door under; Door.find takes it back.


readonly id: number

Defined in: server/api.d.ts:8765

Immutable network entity identifier.

Entity.id


readonly keyItem: string

Defined in: server/api.d.ts:5599

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: boolean

Defined in: server/api.d.ts:5584

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.


readonly lockedByServer: boolean

Defined in: server/api.d.ts:5589

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.


readonly lockpickable: boolean

Defined in: server/api.d.ts:5604

Whether the level lets this door be lockpicked. A lockpick reported on one that cannot be is refused.


readonly name: string

Defined in: server/api.d.ts:5594

The entity name the level gives the door.


readonly open: boolean

Defined in: server/api.d.ts:5574

Whether the door is standing open. Change it with setOpen, which also says which way it swings.


readonly openedFromFront: boolean

Defined in: server/api.d.ts:5579

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: Vector3

Defined in: server/api.d.ts:8775

Authoritative world-space position; assignment forces replicated state.

Entity.position


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.

Entity.rotation


readonly startsLocked: boolean

Defined in: server/api.d.ts:5614

Whether the level builds this door locked, which is the state it has at boot.


readonly state: 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.

Entity.state


readonly stateToken: number

Defined in: server/api.d.ts:5569

Bumped on every durable change. Clients act on the edges rather than the value, so it only tells one change from the next.


readonly virtualWorld: number

Defined in: server/api.d.ts:8770

Current virtual-world identifier.

Entity.virtualWorld