Created
September 1, 2019 13:44
-
-
Save DemmyDemon/9c441a6f9fbff2efcb4789aa9cd73788 to your computer and use it in GitHub Desktop.
Just some zoomy Vendetta bits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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