-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Default script - does nothing. g_torch_angle = math.rad(55) g_torch_dist = 35 g_torch_list = {} function torch_init(e) GravityOff(e) end function torch_main(e) local Px, Py, Pz = g_PlayerPosX, g_PlayerPosY, g_PlayerPosZ local Ay = math.rad(g_PlayerAngY) local PlayerVertAngle = g_PlayerAngX local dist = g_torch_dist local Ang = g_torch_angle local offsetx, offsetz = dist * math.sin(Ay), dist * math.cos(Ay) -- Put this in because the angle appears to be behaving strangely -- Up goes from 360 -> 280, Down goes 0 -> 85! if PlayerVertAngle < 280 then PlayerVertAngle = -PlayerVertAngle else PlayerVertAngle = 2 * (360 - PlayerVertAngle) end offsetx = offsetx + dist * math.sin(Ay - Ang) offsetz = offsetz + dist * math.cos(Ay - Ang) if g_torch_list[e] == nil then g_torch_list[e] = {has_flame = false, static = false, x = 0, y = 0, z = 0}; end g_torch_list[e].x = Px + offsetx g_torch_list[e].y = Py - 30 + PlayerVertAngle / 2 g_torch_list[e].z = Pz + offsetz SetPosition(e, g_torch_list[e].x, g_torch_list[e].y, g_torch_list[e].z) SetRotation(e, 0, math.deg(Ay - math.pi - (Ang / 2)), 0) end