From beb67b79a55638359f66ae245dc5aa6fe23ec27f Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Tue, 7 Oct 2025 21:07:31 +0100 Subject: [PATCH] Auto adjust boxes with poorly set minZ and maxZ Automatically adjusts box targets for custom locations that have been set wrong if minZ is too high, adjust it if maxZ is too low, adjust it and warn the client that the target has to be adjusted. Solves people opening tickets because they half edited a location without reading my docs --- shared/helpers.lua | 14 ++++++++++++++ shared/targets.lua | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/shared/helpers.lua b/shared/helpers.lua index f26f4d6..a8ab573 100644 --- a/shared/helpers.lua +++ b/shared/helpers.lua @@ -956,4 +956,18 @@ end function GetEntityForwardVector(entity) local heading = math.rad(GetEntityHeading(entity) + 90) return vec3(math.cos(heading), math.sin(heading), 0.0) +end + +function adjustMinMaxZ(coord, table) + local table = table + local adMinZ, adMaxZ = false, false + if table.minZ > coord.z then + adMinZ = true + table.minZ = (coord.z - 1.05) + end + if table.maxZ < coord.z then + adMinZ = true + table.maxZ = (coord.z + 0.80) + end + return table.minZ, table.maxZ, adMinZ, adMaxZ end \ No newline at end of file diff --git a/shared/targets.lua b/shared/targets.lua index e90d5fa..d336831 100644 --- a/shared/targets.lua +++ b/shared/targets.lua @@ -336,6 +336,13 @@ function createBoxTarget(data, opts, dist) local script = targetFunc[i] if isStarted(script.targetName) then debugPrint("^6Bridge^7: ^2Creating new ^3Box ^2target with ^6"..script.targetName.." ^7"..data[1]) + if data[5].minZ or data[5].maxZ then + local adMinZ, adMaxZ + data[5].minZ, data[5].maxZ, adMinZ, adMaxZ = adjustMinMaxZ(data[2], { minZ = data[5].minZ, maxZ = data[5].maxZ }) + if adMinZ or adMaxZ then + print("^5Debug^7: ^2Auto adjusted ^7'^4"..data[1].."^7' ^2minZ and maxZ because ^1they weren't set correctly ^2remove or fix them for this target") + end + end local target = script.boxTarget(data, opts, dist) boxTargets[#boxTargets + 1] = target return target