Divergent/mods/Free Zoom/gamedata/scripts/Free_ZoomV2.script

30 lines
1020 B
Plaintext

local zoom_keybind = 341
local get_fov = 0
local get_hud_fov = 0
local get_mouse_sens= 0
local custom_zoom = false
function on_key_press(key)
if not (key == zoom_keybind) then return end
get_fov = ui_options.get("video/basic/fov")
get_hud_fov = ui_options.get("video/basic/hud_fov")
get_mouse_sens = ui_options.get("control/general/mouse_sens")
get_console():execute("fov " .. get_fov * 0.466)
get_console():execute("hud_fov " .. get_hud_fov * 0.466)
get_console():execute("mouse_sens " .. get_mouse_sens * 0.466)
custom_zoom = true
end
function on_key_release(key)
if not (key == zoom_keybind) then return end
if not (custom_zoom) then return end
get_console():execute("fov " .. get_fov)
get_console():execute("hud_fov " .. get_hud_fov)
get_console():execute("mouse_sens " .. get_mouse_sens)
custom_zoom = false
end
function on_game_start()
RegisterScriptCallback("on_key_press",on_key_press)
RegisterScriptCallback("on_key_release",on_key_release)
end