zones.poly
zones.poly(def: table): Zone
Creates a zone from a polygon, with a bottom and a top.
| Field | Type | Role |
|---|---|---|
points |
{ {x, y} } |
outline, at least 3 points; L-shaped and round outlines are fine |
zmin, zmax |
number |
bottom (included) and top (not included) |
name |
string |
name, shown in the console |
onEnter |
(zone, player, reason) -> () |
someone enters |
onExit |
(zone, player, reason) -> () |
someone leaves |
inside |
(zone, player) -> () |
called regularly for each member |
insideEvery |
number |
seconds between two calls to inside (0.25 by default) |
exitMargin |
number |
metres to go past in order to leave, from 0 to 5 (0.25 by default) |
priority |
number |
overlapping zones: the highest wins |
who |
string |
"players" (default), "entities" or "all" |
bucket |
number |
bucket set on entry and given back on exit, without any other code |
holes |
{ table } |
shapes removed from the zone |
data |
table |
free fields, read through zone.data |
debug |
boolean |
thick outline, for debugging |
Parameters#
- def (
table): fields below
Example#
zones.poly({
name = "Potions classroom",
points = { {0, 0}, {10, 0}, {10, 4}, {4, 4}, {4, 10}, {0, 10} },
zmin = 0, zmax = 4,
onEnter = function(zone, player) player:setBucket(140, zone) end,
onExit = function(zone, player) player:clearBucket(zone) end,
})
Notes#
- The outline is refused, with the reason, if it crosses or touches itself, repeats a point or has no area.