-- LUA Script - precede every function and global member with lowercase name of script + '_main' local Q = require "scriptbank\\quatlib" local U = require "scriptbank\\utillib" local rad = math.rad local deg = math.deg local abs = math.abs local acos = math.acos g_measuring_rods = {} function measuring_rod_init(e) end local function angleDiff( e, q1, q2 ) local cq = Q.Conjugate( q1 ) local xda, yda, zda = Q.ToEuler( Q.Mul( cq, q2 ) ) local x1o, y1o, z1o = U.Rotate3D( 0, 1, 0, xda, yda, zda ) PromptLocal( e, x1o .. ", " .. y1o .. ", " .. z1o ) return 0 end function measuring_rod_main( e ) StopAnimation( e ) SetAnimationFrame( e, 0 ) local Ent = g_Entity[ e ] local te = g_measuring_rods[ e ] if te == nil then local x, y, z, xA, yA, zA = GetObjectPosAng( Ent.obj ) g_measuring_rods[ e ] = { x = x, y = y, z = z, q = Q.FromEuler( rad( xA ), rad( yA ), rad( zA ) ) } return end for k, v in pairs( g_measuring_rods ) do if k ~= e then local DX, DY, DZ = v.x - te.x, v.y - te.y, v.z - te.z -- local ang = angleDiff( e, v.q, te.q ) -- PromptLocal(e, math.sqrt(DX * DX + DZ * DZ)) PromptLocal(e, DX .. ", " .. DY .. ", " .. DZ ) end end end