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

SmartObject

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

A bench, a bed, a dice table, an alchemy table, a smithy, a drying rack or a smokehouse a script or a World Builder export placed. Every player in its virtual world can sit on it, sleep in it or work at it as they would at the level’s own. It never moves: assigning position or rotation, or calling setVirtualWorld, is put back on the next tick.

new SmartObject(id): SmartObject

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

Wraps a smart object the server already holds; use SmartObject.spawn to place one.

number

Network entity identifier.

SmartObject

Entity.constructor

destroy(): void

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

Takes the smart object down for every player. A player sitting on it or working at it is let go.

void


setVirtualWorld(world): void

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

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

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


toJSON(): SmartObjectDefinition | null

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

The definition SmartObject.spawn takes to place it again: what a script saves. The server keeps nothing past a restart. It is one entry of a World Builder map’s smartObjects array.

SmartObjectDefinition | null

Null once it is gone.


toString(): string

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

Formats this handle for logging and debugging.

string

Its id, blueprint and kind.

Entity.toString


static all(virtualWorld?): SmartObject[]

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

Lists the smart objects scripts and World Builder exports placed.

number

Optional virtual world to list; omitted lists every one.

SmartObject[]

One handle per placed object, in no particular order.


static blueprints(): SmartObjectBlueprintInfo[]

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

Lists everything SmartObject.spawn can place.

SmartObjectBlueprintInfo[]

One row per blueprint, sorted by name.


static getById(id): SmartObject | null

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

Looks a placed smart object up by its network entity ID.

number

Network entity identifier.

SmartObject | null

The handle, or null.


static remove(id, virtualWorld?): void

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

Takes one of the level’s stations out of a virtual world through a level edit on its entity: listed nowhere, refused for any new session by the server (one already running at it finishes), and hidden on every client seeing that world – a player in the global world sees every world. The furniture around it is the level’s own scenery and stays; take it out with LevelEdit.apply or the World Builder. A placed smart object goes with destroy() instead. Kept in memory only, like every level edit.

string

The level station’s GUID, as SmartObject.stations() lists it.

number

Optional virtual world to take it out of; the global one, and so every world, when omitted.

void

Throws for an id that is not one of the level’s stations.


static removed(virtualWorld?): RemovedStation[]

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

Lists the level’s stations a level edit has taken out, by a script or a World Builder export alike.

number

Optional virtual world to list; omitted lists every one.

RemovedStation[]

One row per removal, in no particular order.


static restore(id, virtualWorld?): boolean

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

Puts back one of the level’s stations that a level edit took out of a virtual world.

string

The level station’s GUID, as SmartObject.removed() lists it.

number

Optional virtual world to put it back in; the global one when omitted.

boolean

False when that world had no such removal.


static spawn(definition, virtualWorld?): SmartObject

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

Places one of the game’s interactive prefabs – its furniture, solid, and the entities its interaction runs on – for every player in the virtual world, built on each client under the same GUIDs, so sitting on it and working at it replicate as they do at the level’s own. A placed dice table, crafting station, drying rack or smokehouse joins Dice.tables(), Crafting.stations() and the server’s checks like the level’s own. Kept in memory only: place it again on boot. The resource that places it owns it, so it goes when that resource stops. NPCs do not use it. A bare definition places the entities without the furniture, where a prop of your own stands.

SmartObjectDefinition

What to place and where, in the format of one entry of a World Builder map’s smartObjects array.

number

Optional virtual world whose players see it; the global one when omitted.

SmartObject

The smart object. Throws for an unknown blueprint, a transform that is not finite, or bare on a blueprint that cannot stand bare.


static stations(virtualWorld?): SmartObjectStation[]

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

Lists every station players in a virtual world can use: the level’s dice tables, crafting stations, drying racks and smokehouses, minus any a level edit took out of that world, and every placed one there or in the global world.

number

Optional virtual world to list for; the global one when omitted.

SmartObjectStation[]

One row per station, in no particular order.

readonly bare: boolean

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

Whether it was placed without its blueprint’s furniture: only the place a body takes, or the station, and the prompts that offer it.


readonly blueprint: string

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

The blueprint it was placed from, as SmartObject.blueprints() lists it.


readonly id: number

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

Immutable network entity identifier.

Entity.id


readonly kind: "alchemy" | "smithing" | "seat" | "bed" | "dice" | "drying" | "smoking"

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

What it is for.


readonly name: string

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

The name it was placed with; empty for none.


position: Vector3

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

Authoritative world-space position; assignment forces replicated state.

Entity.position


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.

Entity.rotation


readonly seats: string[]

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

The GUIDs of the places a body sits or lies on, as a seated player’s stance and DiceTableInfo.seats name them.


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

Entity.state


readonly stationId: string

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

The GUID of its station part as sixteen lowercase hex digits: the id Dice.tables() and SmartObject.stations() give it. Crafting.stations() lists an alchemy table or a smithy as <level>:<stationId>. Empty for a seat or a bed. It lasts only until the server stops.


readonly virtualWorld: number

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

Current virtual-world identifier.

Entity.virtualWorld