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
This commit is contained in:
Jim Shield
2025-10-07 21:07:31 +01:00
parent c359bc4342
commit beb67b79a5
2 changed files with 21 additions and 0 deletions

View File

@@ -957,3 +957,17 @@ 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

View File

@@ -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