forked from hkc/cc-stuff
1
0
Fork 0

wallhack: print distance to each entity

This commit is contained in:
Vftdan 2023-10-14 12:14:25 +03:00
parent e8e980cbae
commit 3e2835419d
1 changed files with 5 additions and 1 deletions

View File

@ -30,6 +30,10 @@ return function()
return {x = u.x + v.x, y = u.y + v.y, z = u.z + v.z}
end
local function vec3Abs(v)
return math.sqrt(dotProduct3(v, v))
end
local function toFrontCoords(entity)
local dotResult = dotProduct3(entity, playerLookVector)
if dotResult >= 0.0 then
@ -80,7 +84,7 @@ return function()
if player.isSneaking then
cache[id].text.setText(entity.name .. "\n" .. textutils.serialize(entity))
else
cache[id].text.setText(("%s\n{%.2f, %.2f, %.2f}"):format(entity.name, entity.x, entity.y, entity.z))
cache[id].text.setText(("%s\n|{%.2f, %.2f, %.2f}| = %.2f"):format(entity.name, entity.x, entity.y, entity.z, vec3Abs(entity)))
end
if entityFront.flipped then
cache[id].text.setColor(0x00FFFFFF)