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

Cart

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

Replicated cart or wagon handle.

new Cart(id): Cart

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

Creates a script wrapper for an existing cart with this ID; use Cart.spawn() to spawn one.

number

Network entity identifier.

Cart

Entity.constructor

destroy(): void

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

Despawns this cart on every client. Everyone in it is let out first, each with a cartExit, then cartDestroy is raised.

void


getOccupant(seat): Player | null

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

Who sits in a seat.

string

One of the cart’s seats.

Player | null

The player in it, or null when it is empty.


putPlayer(player, seat): boolean

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

Puts a player in a seat. They are taken out of any cart they were in, their own game walks them to the seat and climbs in, and cartEnter follows; the driver’s client runs the cart from then on. cartEntering handlers are asked first.

Player

The player to seat.

string

One of the cart’s seats. A wagon has driver (the reins, on the bench’s left), bench (beside them), rightBack, leftBack, rightFront and leftFront (on the rails); the two-wheeler driver, rightBack and leftBack.

boolean

Whether the player was seated: false for a taken seat, a player that is not connected, or a handler’s refusal.


removePlayer(player): boolean

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

Lets a player out of this cart: their own game climbs down, and cartExit is raised.

Player

The player to let out.

boolean

False when the player is not in this cart.


seatOf(player): string | null

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

Where a player sits in this cart.

Player

The player to look for.

string | null

The seat’s name, one of seats, or null when they are not in it.


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


teleport(position, rotation?): boolean

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

Moves the cart outright, standing, with everyone in it; a driver carries on from there.

Vector3

Where the cart’s front axle stands.

Vector3 | Quaternion

Which way it faces; omitted keeps its heading.

boolean

False for a pose that is not finite.


toString(): string

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

Formats this cart handle for logging and debugging.

string

The cart ID, its blueprint, its driver and its pace.

Entity.toString


static all(virtualWorld?): Cart[]

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

Lists the carts the server has.

number

Optional virtual world to list; omitted lists every one.

Cart[]

One handle per live cart, in no particular order.


static blueprints(): string[]

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

Names every cart prefab Cart.spawn can build.

string[]

The blueprint names, in catalog order.


static destroyAll(virtualWorld?): number

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

Despawns carts, emitting cartDestroy for each one.

number

Optional virtual world to clear; omitted clears every one of them.

number

How many carts were removed.


static getById(id): Cart | null

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

Looks a cart up by its network entity ID.

number

Network entity identifier.

Cart | null

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


static spawn(blueprint?, position?, rotation?, virtualWorld?): Cart

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

Spawns and replicates a cart or wagon from the game’s own prefabs, with its horses already in the shafts. It stands where it was put until somebody takes the reins.

string

Which of the game’s cart prefabs to build; omitted builds wagon_b_covered. Cart.blueprints() lists them.

Vector3 | Partial<Vector3>

Where the cart’s front axle stands; omitted components default to zero.

Vector3 | Quaternion

Which way it faces: a Quaternion, or a Vector3 of Euler angles in degrees.

number

Optional virtual world the cart belongs to; omitted puts it in the global one.

Cart

The newly spawned cart handle.

readonly blueprint: string

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

The game prefab this cart was built from, e.g. wagon_b_covered. Cart.blueprints() lists them all.


readonly driver: Player | null

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

The player at the reins, or null when nobody drives it.


readonly horseCount: number

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

How many horses the cart is harnessed for: 2 for a wagon, 1 for the two-wheeled cart, 0 for wagon_b_covered_empty, whose chassis has nowhere to hitch one and so can be sat in but never pulled.


readonly id: number

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

Immutable network entity identifier.

Entity.id


maxSpeed: number

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

The fastest the driver may take it urged on (the trot key held), in metres a second, 0 to 15; 7 by default. Unurged the team trots at 3.6 or this, whichever is less. A value outside the range is ignored.


readonly pace: string

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

How the driver last asked the cart to go: stand, walk, trot or reverse.


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 seats: string[]

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

The names of this cart’s seats, the reins first: six on a wagon, three on the two-wheeler.


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 virtualWorld: number

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

Current virtual-world identifier.

Entity.virtualWorld