Divergent/mods/FDDA/gamedata/scripts/fov_anim_manager.script

37 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2024-03-17 20:18:03 -04:00
--[[
Fov animation manager script
Author: Tronex
--]]
local fov_prev
-- axr_options.ltx will handle saving fov changes during animation, if something breaks during it, it will restore previous cached FOV
function on_game_start()
local function actor_on_first_update()
local fov_changed = axr_main.config:r_value("temp", "fov_changed", 1)
local fov_value = axr_main.config:r_value("temp", "fov_value", 2)
if fov_changed and (type(fov_value) == "number") then
exec_console_cmd("hud_fov " .. fov_value)
end
axr_main.config:w_value("temp", "fov_changed", false)
end
RegisterScriptCallback("actor_on_first_update",actor_on_first_update)
end
function change_fov(value) -- change_fov(0.45)
local fov = get_console_cmd(2, "hud_fov")
if (fov ~= value) then
exec_console_cmd("hud_fov " .. value)
fov_prev = fov
axr_main.config:w_value("temp", "fov_changed", true)
axr_main.config:w_value("temp", "fov_value", fov)
end
end
function restore_fov()
if fov_prev then
exec_console_cmd("hud_fov " .. fov_prev)
fov_prev = nil
axr_main.config:w_value("temp", "fov_changed", false)
end
end