Zone
Defined in: server/api.d.ts:5078
A server volume that reports entities crossing it, from the positions the server already has, checked 10 times a second. Events: zoneEntered(zone, entity); zoneExit(zone, entity | null, reason, entityId) with reason “left”, or “gone” when the entity no longer exists (entity is then null). An entity inside when the zone is created gets zoneEntered at the next check. A mover that crosses the zone between two checks gets zoneEntered then zoneExited back to back. Destroying a zone, or replacing it under the same key, sends no zoneExited. A resource’s zones are destroyed when it stops. A zone with a hazard (options.hazard, setHazard) also hurts, fogs and tints the players inside it, and raises zoneHazard(zone, player, exposed, playerId) as their exposure changes.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Zone(
id):Zone
Defined in: server/api.d.ts:5083
Wraps a zone id; see valid.
Parameters
Section titled “Parameters”number
Zone id.
Returns
Section titled “Returns”Zone
Methods
Section titled “Methods”contains()
Section titled “contains()”contains(
point):boolean
Defined in: server/api.d.ts:5129
Whether the point is inside. Ignores virtual worlds.
Parameters
Section titled “Parameters”A world position; a Vector3 works.
number
number
number
Returns
Section titled “Returns”boolean
destroy()
Section titled “destroy()”destroy():
boolean
Defined in: server/api.d.ts:5174
Destroys the zone. No zoneExited is sent.
Returns
Section titled “Returns”boolean
getEntities()
Section titled “getEntities()”getEntities(): (
Player|Character|Beast|NPC|WorldObject)[]
Defined in: server/api.d.ts:5139
Every tracked entity inside as of the last check.
Returns
Section titled “Returns”(Player | Character | Beast | NPC | WorldObject)[]
getHazard()
Section titled “getHazard()”getHazard():
ZoneHazard|null
Defined in: server/api.d.ts:5144
Its hazard with every default filled in; null when it has none or is destroyed.
Returns
Section titled “Returns”ZoneHazard | null
getPlayers()
Section titled “getPlayers()”getPlayers():
Player[]
Defined in: server/api.d.ts:5134
The players inside as of the last check.
Returns
Section titled “Returns”Player[]
getShape()
Section titled “getShape()”getShape():
ZoneShape|null
Defined in: server/api.d.ts:5118
Its shape as created; null once destroyed.
Returns
Section titled “Returns”ZoneShape | null
getTrack()
Section titled “getTrack()”getTrack(): (
"beast"|"player"|"npc"|"worldObject"|"character")[]
Defined in: server/api.d.ts:5123
The entity kinds it reports.
Returns
Section titled “Returns”("beast" | "player" | "npc" | "worldObject" | "character")[]
isExposed()
Section titled “isExposed()”isExposed(
player):boolean
Defined in: server/api.d.ts:5169
Whether the last check found the player inside and unprotected.
Parameters
Section titled “Parameters”player
Section titled “player”Who to ask about.
Returns
Section titled “Returns”boolean
protect()
Section titled “protect()”protect(
player,seconds):boolean
Defined in: server/api.d.ts:5157
Protects a player from this zone’s hazard for a while, inside or not yet, replacing what was left. Holding a protection item still protects on top. False once the zone is destroyed.
Parameters
Section titled “Parameters”player
Section titled “player”Who to protect.
seconds
Section titled “seconds”number
How long, 0 to 86400; 0 ends a protection now.
Returns
Section titled “Returns”boolean
protectedFor()
Section titled “protectedFor()”protectedFor(
player):number
Defined in: server/api.d.ts:5163
Seconds of protection left from a consumable or protect(), 0 when none. Items held are not counted.
Parameters
Section titled “Parameters”player
Section titled “player”Who to ask about.
Returns
Section titled “Returns”number
setHazard()
Section titled “setHazard()”setHazard(
hazard):boolean
Defined in: server/api.d.ts:5150
Gives the zone a hazard, or takes it off. Players inside hear of it at the next check. False once the zone is destroyed; a TypeError on a bad hazard.
Parameters
Section titled “Parameters”hazard
Section titled “hazard”ZoneHazard | null
The new hazard, replacing the old one whole; null takes it off.
Returns
Section titled “Returns”boolean
create()
Section titled “create()”
staticcreate(key,shape,options?):Zone
Defined in: server/api.d.ts:5182
Creates or replaces a zone. Throws a TypeError on a bad shape or option, and an Error at 4096 zones.
Parameters
Section titled “Parameters”string
Stable key; creating again replaces the zone.
The volume.
options?
Section titled “options?”Virtual world and the entity kinds to report.
Returns
Section titled “Returns”Zone
destroy()
Section titled “destroy()”
staticdestroy(key):boolean
Defined in: server/api.d.ts:5194
Destroys the zone under a key. No zoneExited is sent.
Parameters
Section titled “Parameters”string
Key passed to create.
Returns
Section titled “Returns”boolean
staticget(key):Zone|undefined
Defined in: server/api.d.ts:5188
The zone under a key.
Parameters
Section titled “Parameters”string
Key passed to create.
Returns
Section titled “Returns”Zone | undefined
getAll()
Section titled “getAll()”
staticgetAll():Zone[]
Defined in: server/api.d.ts:5199
Every zone, oldest first.
Returns
Section titled “Returns”Zone[]
Properties
Section titled “Properties”
readonlyid:number
Defined in: server/api.d.ts:5088
Zone id, unique for the server’s lifetime.
readonlykey:string
Defined in: server/api.d.ts:5098
The key it was created under; empty once destroyed.
readonlymap:string
Defined in: server/api.d.ts:5113
The map it is in; empty for the shared map.
readonlytype:""|"sphere"|"box"|"cylinder"|"polygon"
Defined in: server/api.d.ts:5103
Its shape’s type; empty once destroyed.
readonlyvalid:boolean
Defined in: server/api.d.ts:5093
Whether the zone still exists.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: server/api.d.ts:5108
The virtual world it watches.