From 8081132d6fb04fd8bf36918b7f8ee8ee82d6f5bb Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 12 May 2022 17:37:42 +1000 Subject: [PATCH] more zone examples --- docs/ox_lib/Client/zones.md | 68 +++++++++++++++++++++++++++-------- docs/ox_lib/Shared/version.md | 4 +-- 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/docs/ox_lib/Client/zones.md b/docs/ox_lib/Client/zones.md index e42ce075..67db2811 100644 --- a/docs/ox_lib/Client/zones.md +++ b/docs/ox_lib/Client/zones.md @@ -1,10 +1,10 @@ # Zones -More optimised version of polyzones utilising glm polygon. +An alternative to PolyZone utilising [glm.polygon](https://github.com/gottfriedleibniz/lua/blob/luaglm/EXTENDED.md#polygon). ```lua -- data: table - -- points: table of vector3s, all z values must match + -- points: vector3[] all z values must match -- thickness: number (optional), default 2 -- debug: bool (optional) lib.zones.poly(data) @@ -21,21 +21,59 @@ lib.zones.box(data) -- radius: number (optional), default is 2 -- debug: bool (optional) lib.zones.sphere(data) +``` -local zone = lib.points.box({ - coords = playerCoords, - dunak = 'nerd', +```lua +function onEnter(self) + print('entered zone', self.id) +end + +function onExit(self) + print('exited zone', self.id) +end + +function inside(self) + print('you are inside zone ' .. self.id) +end + +local poly = lib.zones.poly({ + points = { + vec(413.8, -1026.1, 29), + vec(411.6, -1023.1, 29), + vec(412.2, -1018.0, 29), + vec(417.2, -1016.3, 29), + vec(422.3, -1020.0, 29), + vec(426.8, -1015.9, 29), + vec(431.8, -1013.0, 29), + vec(437.3, -1018.4, 29), + vec(432.4, -1027.2, 29), + vec(424.7, -1023.5, 29), + vec(420.0, -1030.2, 29), + vec(409.8, -1028.4, 29), + }, + thickness = 2, + debug = true, + inside = inside, + onEnter = onEnter, + onExit = onExit }) -function zone:onEnter() - print('entered box', self.id) -end +local sphere = lib.zones.sphere({ + coords = vec3(442.5363, -1017.666, 28.65637), + radius = 1, + debug = true, + inside = inside, + onEnter = onEnter, + onExit = onExit +}) -function zone:onExit() - print('exited box', self.id) -end - -function zone:inside() - print('you are inside the box ' .. self.id) -end +local box = lib.zones.box({ + coords = vec3(442.5363, -1017.666, 28.65637), + size = vec3(1, 1, 1), + rotation = 45, + debug = true, + inside = insideZone, + onEnter = onEnter, + onExit = onExit +}) ``` diff --git a/docs/ox_lib/Shared/version.md b/docs/ox_lib/Shared/version.md index 9e42c446..2cd873a5 100644 --- a/docs/ox_lib/Shared/version.md +++ b/docs/ox_lib/Shared/version.md @@ -3,9 +3,9 @@ ### lib.checkDependency Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors. ```lua --- repository: string +-- resource: string -- version: string -lib.checkDependency(repository, version) +lib.checkDependency(resource, version) if not lib.checkDependency('ox_lib', '1.5.0') then error() end ```