-- LUA Script - precede every function and global member with lowercase name of script + '_main' g_torch_flame_list = {} g_torch_list = {} g_player_torch_flame = nil function torch_flame_init(e) GravityOff(e) SetFlashLightKeyEnabled(0) -- disables the flash light key from being used end function torch_flame_main(e) local torch = nil if g_torch_flame_list[e] == nil then for k, _ in pairs (g_torch_list) do if not g_torch_list[k].has_flame then g_torch_flame_list[e] = k g_torch_list[k].has_flame = true g_torch_list[k].flame_positioned = false g_torch_list[k].flame_lit = false break end end end RotateToCamera(e) torch = g_torch_flame_list[e] if torch ~= nil then if g_torch_list[torch].static then if not g_torch_list[torch].flame_positioned then local angle = math.rad(g_Entity[torch].angley) SetPosition(e, g_torch_list[torch].x - 25 * math.sin(angle), g_torch_list[torch].y + 180, g_torch_list[torch].z - 25 * math.cos(angle)); Scale(e, 250) Hide(e) g_torch_list[torch].flame_positioned = true end if g_torch_list[torch].flame_positioned and not g_torch_list[torch].flame_lit then local my_flame = g_Entity[e] local pl_flame = g_Entity[g_player_torch_flame] if my_flame ~= nil and pl_flame ~= nil then local DX, DY, DZ = my_flame.x - pl_flame.x, my_flame.y - pl_flame.y, my_flame.z - pl_flame.z; if (DX*DX + DY*DY + DZ*DZ) < 50*50 then g_torch_list[torch].flame_lit = true Show(e) end end end else if g_player_torch_flame == nil then SetFlashLight(1) -- switches the flash light on g_player_torch_flame = e end local Ay = math.rad(g_PlayerAngY) local Ang = g_torch_angle local offsetx = 3 * math.sin(Ay - Ang) local offsetz = 3 * math.cos(Ay - Ang) SetPosition(e, g_torch_list[torch].x - offsetx, g_torch_list[torch].y + 87 , g_torch_list[torch].z - offsetz); Scale(e, 260) end end end