Skip to content

Instantly share code, notes, and snippets.

@DemmyDemon
Created September 1, 2019 13:44
Show Gist options
  • Save DemmyDemon/9c441a6f9fbff2efcb4789aa9cd73788 to your computer and use it in GitHub Desktop.
Save DemmyDemon/9c441a6f9fbff2efcb4789aa9cd73788 to your computer and use it in GitHub Desktop.
Just some zoomy Vendetta bits
local zZoom = {
current = tonumber(Game.GetCVar('fov') or 90),
target = 90,
step = 10,
min = 20,
max = 90,
reset = 90,
verbose = false,
}
local function say(message)
if zZoom.verbose then
print(message)
end
end
zZoom.zoomIn = function()
zZoom.target = math.max(zZoom.min, zZoom.target - zZoom.step)
say('ZoomIn: '..zZoom.target)
end
zZoom.zoomOut = function()
zZoom.target = math.min(zZoom.max, zZoom.target + zZoom.step)
say('ZoomOut: '..zZoom.target)
end
zZoom.zoomTo = function(data, args)
local value = tonumber(args[1])
if type(value) == 'number' then
zZoom.target = math.max(math.min(value, zZoom.max), zZoom.min)
say("Zoomed to "..zZoom.target)
elseif type(value) ~= nil then
print("Must zoom to a number value ("..value..")")
else
print("... zoom to what?")
end
end
zZoom.resetZoom = function()
zZoom.target = zZoom.reset
say('Zoom Reset!')
end
zZoom.frame = function(handle)
local step = 1
if zZoom.current ~= zZoom.target then
if zZoom.target > zZoom.current then
zZoom.current = math.min(zZoom.current + step, zZoom.target)
else
zZoom.current = math.max(zZoom.current - step, zZoom.target)
end
Game.SetCVar('fov',math.floor(zZoom.current))
end
if zZoom.timer then
zZoom.timer:SetTimeout(10, zZoom.frame)
end
end
RegisterUserCommand("zzoomin",zZoom.zoomIn)
RegisterUserCommand("zzoomout",zZoom.zoomOut)
RegisterUserCommand("zzoomreset",zZoom.resetZoom)
RegisterUserCommand("zzoomto",zZoom.zoomTo)
zZoom.timer = Timer()
zZoom.timer:SetTimeout(10, zZoom.frame)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment