Skip to content

gdmp.zones

Rectangles (or circles) players enter and leave; evaluated on every tick from the players’ positions.

Call What it does
add({id, x, y, width, height}) / add({id, x, y, radius}) x, y = the bottom-left corner (rectangle) or the centre (circle)
remove(id) / list()
onEnter(cb) / onLeave(cb) cb({zone, playerId, player}); player is null when that player is gone (left). A Studio zone has the id studio:<name>

The declarations from the GDMP types (namespace GDMP), comments included:

type Zone =
| { id: string; x: number; y: number; width: number; height: number }
| { id: string; x: number; y: number; radius: number };
/** `player` is null when that player is gone (left / disconnected). */
interface ZoneEvent { readonly zone: string; readonly playerId: PlayerId; readonly player: Player | null }
interface Zones {
add(zone: Zone): boolean;
remove(id: string): boolean;
list(): Zone[];
onEnter(cb: Callback<[event: ZoneEvent]>): void;
onLeave(cb: Callback<[event: ZoneEvent]>): void;
}