From d2c5be8ea83dcba38d174df253610f7ac0a92b5c Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 27 Jul 2023 00:38:36 +1000 Subject: [PATCH] fix(client/zones): setDebug early return --- imports/zones/client.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/imports/zones/client.lua b/imports/zones/client.lua index 6a2b852..0a33515 100644 --- a/imports/zones/client.lua +++ b/imports/zones/client.lua @@ -6,7 +6,7 @@ local glm = require 'glm' ---@field distance number ---@field type 'poly' | 'sphere' | 'box' ---@field debugColour vector4? ----@field setDebug fun(self: CZone) +---@field setDebug fun(self: CZone, enable?: boolean, colour?: vector) ---@field remove fun() ---@field contains fun(self: CZone, coords?: vector3): boolean ---@field onEnter fun(self: CZone)? @@ -267,10 +267,16 @@ local function setDebug(self, bool, colour) self.debugColour = bool and vec4(colour?.r or self.debugColour?.r or 255, colour?.g or self.debugColour?.g or 42, colour?.b or self.debugColour?.b or 24, colour?.a or self.debugColour?.a or 100) or nil - if bool and self.debug or not bool and not self.debug then return end + if not bool and self.debug then + self.triangles = nil + self.debug = nil + return + end - self.triangles = bool and (self.type == 'poly' and getTriangles(self.polygon) or self.type == 'box' and { mat(self.polygon[1], self.polygon[2], self.polygon[3]), mat(self.polygon[1], self.polygon[3], self.polygon[4]) }) or nil - self.debug = bool and (self.type == 'sphere' and debugSphere or debugPoly) or nil + if bool and self.debug and self.debug ~= true then return end + + self.triangles = self.type == 'poly' and getTriangles(self.polygon) or self.type == 'box' and { mat(self.polygon[1], self.polygon[2], self.polygon[3]), mat(self.polygon[1], self.polygon[3], self.polygon[4]) } or nil + self.debug = self.type == 'sphere' and debugSphere or debugPoly or nil end lib.zones = {