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

LevelEdit

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

One change the server makes, for every player, to an object the level itself placed – a brush, a tree or a level entity taken out of the world, moved, swapped for another mesh, or a mix of those – or to the grass: the tall grass, flowers and ferns the level bakes into its terrain are not objects, and a grass edit takes out every one of them rooted in a box. It is what a World Builder map’s world array carries. WorldRayHit.levelObject names the object a trace met in the form apply takes.

new LevelEdit(id): LevelEdit

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

Wraps an edit the server already holds; use LevelEdit.apply to make one, or WorldResource for a whole export.

number

Network entity identifier.

LevelEdit

clearMove(): void

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

Puts the object back where the level placed it, keeping it out of the world if the edit takes it out.

void


move(position, rotation?, scale?): boolean

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

Moves the object for every player, collision included.

Vector3

Where the object stands instead.

Vector3 | Quaternion

Its orientation: a Quaternion, or Euler angles in degrees. Left out, it keeps the last move’s.

number | Vector3

A uniform scale or one per axis, from 0.01 to 100. Left out, it keeps the last move’s.

boolean

False for a gone edit, a transform that is not finite, or a grass edit, whose box is fixed when it is applied.


restore(): void

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

Drops the edit: every player gets the object back exactly as the level had it, collision included.

void


toJSON(): LevelEditDefinition | null

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

The definition LevelEdit.apply takes to make this edit again, which is what a script saves: the server keeps nothing past a restart. It is one entry of a World Builder map’s world array.

LevelEditDefinition | null

Null once the edit is gone.


toString(): string

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

Formats this edit for logging and debugging.

string

Its id, kind, object and what it does to it.


static all(virtualWorld?): LevelEdit[]

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

Lists every edit the server currently has.

number

Optional virtual world to list; omitted lists every one of them.

LevelEdit[]

One handle per live edit, in no particular order.


static apply(definition, virtualWorld?): LevelEdit

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

Takes an object the level placed out of the world, moves it, or swaps it for another mesh, for every player in the virtual world – whenever they join, and however far away they are. Collision goes with it. An edit already made to the same object in that world is restated rather than doubled, so applying one twice changes nothing. Kept in memory only: apply it again on boot. A WorldRayHit.levelObject is a definition already: spread it and add what to do, as in LevelEdit.apply({ ...hit.levelObject, model: stump }).

LevelEditDefinition

The object and what to do to it, in the format of one entry of a World Builder map’s world array.

number

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

LevelEdit

The edit. Throws for a definition no client could find the object by, a model no client could load, or a grass box that is not finite and within its limits.


static getById(id): LevelEdit | null

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

Looks an edit up by its network entity ID.

number

Network entity identifier.

LevelEdit | null

The edit, or null when no live edit has that ID.


static restoreAll(virtualWorld?): number

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

Drops edits, giving every player the objects back as the level had them.

number

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

number

How many edits were dropped.

readonly exists: boolean

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

False once the edit has been restored; every other read then returns its empty value.


readonly guid: string

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

An entity’s level EntityGuid as sixteen lowercase hex digits; empty for a brush.


hidden: boolean

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

Whether the object is taken out of the world: not drawn and not solid. Assignment takes it out or puts it back for every player, keeping any move. For grass, whether the plants in the box are taken out.


readonly id: number

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

Immutable network entity identifier.


readonly kind: "brush" | "entity" | "grass"

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

Whether the object is a brush, found by its mesh and where the level put it, a level entity, found by its EntityGuid, or a box of the terrain’s grass.


model: string

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

The mesh standing in the object’s place, or empty. Assigning a prop catalog path or a mesh this server streams swaps the object for it on every player: the object goes, collision included, and the mesh stands where it stood – or where move put it – as solid static scenery. A felled tree leaves its stump this way. Assigning an empty string gives the object back. Throws for any other path, and for a grass edit.


readonly moved: boolean

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

Whether the object stands somewhere other than where the level placed it; move and clearMove change it.


readonly name: string

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

A brush’s mesh path, or the name the level gives the entity. Empty for grass.


readonly virtualWorld: number

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

The virtual world whose players see the edit, fixed when it was applied.