Noverwyn Documentation

Zones

A zone is a volume of the world. The server tells the script when someone enters or leaves.

Two ways to get one#

By script:

zones.poly({
	name = "Duelling circle",
	points = { { -40, -10 }, { -30, -14 }, { -20, -10 }, { -18, 0 }, { -20, 10 }, { -30, 14 }, { -40, 10 } },
	zmin = -1,
	zmax = 5,
	onEnter = function(_, player) player:set("duel", true) end,
	onExit = function(_, player) player:set("duel", nil) end,
})

Drawn in the map, then found by their data:

for _, stairs in map.zones({ type = "stairs" }) do
	stairs.onEnter = function(zone, player)
		player:teleport(zone.data.to)
	end
end

The second way avoids writing coordinates in code. See Map format.

Shapes#

Function Shape
zones.box box, rotated if you like
zones.sphere sphere
zones.poly polygon with a bottom and a top; L-shaped and round outlines are fine
zones.compound several shapes, a single entry and a single exit

holes removes parts from any zone.

Callbacks#

Function When
onEnter(zone, player, reason) someone enters
onExit(zone, player, reason) someone leaves
inside(zone, player) regularly, for each member (0.25 s by default)
reason Meaning
move crossed the boundary, or was teleported
zone_added the zone appeared around them, or the script just started watching it
zone_removed the zone, or its script, was removed
left disconnected, or entity deleted

Useful rules#

  • The edge: to leave, you must go 25 cm past it (exitMargin). Walking on the line does not make the zone flicker. The margin only applies horizontally.
  • Floors: the bottom is included, the top is not. Two classrooms on top of each other are never confused.
  • Doors do not exist for the server. Open or closed, only crossing matters.
  • Who: players only, by default. who = "entities" or "all" for objects.
  • Teleporting from a zone is allowed. At most four passes per tick prevent endless loops.

Priority#

When overlapping zones each set a bucket, the highest priority wins. If equal, the last one entered wins.