Skip to content
M2O Scripting APIScripting reference
Runtime classServer APIGenerated

Volume

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

A replicated trigger volume. Every client realises it as a native physics sensor, so entry and exit are detected by the game engine rather than polled, and raise volumeHit and volumeLeave.

new Volume(id): Volume

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

Creates a script wrapper for an existing volume with this ID; use Volume.sphere or Volume.box to create one.

number

Network entity identifier.

Volume

Entity.constructor

contains(player): boolean

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

Reports whether a player is currently inside.

number | Player

Player handle or network id to test.

boolean

True when that player’s client last reported entering and has not reported leaving.


destroy(): void

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

Destroys this volume. Every client drops its sensor, and nobody is left recorded inside.

void


getPlayers(): Player[]

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

Lists the players currently inside, as their own clients’ sensors reported them.

Player[]

The players inside the volume.


isInside(x, y, z): boolean

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

Tests a world-space point against the volume’s shape. This is a geometric test: unlike contains() it consults no occupancy, works for a point nobody is standing on, and is unaffected by setEnabled.

number

World-space X coordinate to test.

number

World-space Y coordinate to test.

number

World-space Z coordinate to test.

boolean

True when the point lies inside the shape.


setEnabled(enabled): void

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

Enables or disables the volume. A disabled volume holds nobody inside, so anyone in it leaves first.

boolean

False to drop the sensor on every client.

void


setPosition(x, y, z): void

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

Moves the volume. Every client rebuilds its sensor at the new position.

number

World-space X coordinate of the centre.

number

World-space Y coordinate of the centre.

number

World-space Z coordinate of the centre.

void


setRadius(radius): void

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

Resizes a sphere volume. Ignored by a box.

number

Sphere radius in world units.

void


setRotation(rotation): void

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

Reorients a box volume. The engine applies this to the sensor’s matrix, so the box is genuinely oriented rather than axis-aligned. Ignored by a sphere.

Vector3 | Quaternion

a Quaternion, or a Vector3 of Euler angles in radians

void


setSize(width, depth, height): void

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

Resizes a box volume. These are full extents, not half-extents. Ignored by a sphere.

number

Full size along the volume’s local X axis.

number

Full size along the volume’s local Y axis.

number

Full size along the volume’s local Z axis.

void


setVirtualWorld(virtualWorld): void

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

Moves the volume to a virtual world. Clients in another world never build its sensor, so it cannot fire for them.

number

Virtual world the volume exists in.

void

Entity.setVirtualWorld


setVisibleTo(player): void

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

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

Returns a readable representation of this volume.

string

The volume ID and shape formatted for logging or debugging.

Entity.toString


static box(x, y, z, width, depth, height, rotation?, virtualWorld?): Volume

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

Creates a box trigger volume, realised on every client as a native box sensor. The rotation orients the box itself, which is what a city block or a building footprint needs.

number

World-space X coordinate of the centre.

number

World-space Y coordinate of the centre.

number

World-space Z coordinate of the centre.

number

Full size along the volume’s local X axis.

number

Full size along the volume’s local Y axis.

number

Full size along the volume’s local Z axis.

Vector3 | Quaternion

a Quaternion, or a Vector3 of Euler angles in radians

number

Optional virtual world the volume exists in.

Volume

The new volume.


static getAll(): Volume[]

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

Lists every live volume.

Volume[]

All volumes currently replicated by the server.


static sphere(x, y, z, radius, virtualWorld?): Volume

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

Creates a sphere trigger volume, realised on every client as a native sphere sensor.

number

World-space X coordinate of the centre.

number

World-space Y coordinate of the centre.

number

World-space Z coordinate of the centre.

number

Radius in world units.

number

Optional virtual world the volume exists in.

Volume

The new volume.

readonly enabled: boolean

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

Whether clients currently hold a sensor for this volume.


readonly id: number

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

Immutable network entity identifier.

Entity.id


position: Vector3

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

Authoritative world-space position; assignment forces replicated state.

Entity.position


readonly radius: number

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

Sphere radius in world units; meaningless for a box.


rotation: Vector3 | Quaternion

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

Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.

Entity.rotation


readonly shape: string

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

Primitive this volume was created as: “sphere” or “box”. Empty once destroyed.


readonly size: Vector3

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

Box full extents; meaningless for a sphere.


readonly state: StateBag

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

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

Current virtual-world identifier.

Entity.virtualWorld