Skip to content

Instantly share code, notes, and snippets.

@RobMayer
Last active May 2, 2019 16:50
Show Gist options
  • Save RobMayer/5e39c825dca03541a9f2a72ce1cb9e18 to your computer and use it in GitHub Desktop.
Save RobMayer/5e39c825dca03541a9f2a72ce1cb9e18 to your computer and use it in GitHub Desktop.
[TTS] Auto-Update utility
ScriptVersion = 4
ScriptClass = 'MyUtility'
function checkForUpdate()
WebRequest.get('yourgithubfile.json', function(res)
if (not(res.is_error)) then
local response = JSON.decode(res.text)
if (response[ScriptClass] > ScriptVersion) then
print('New Version ('..response[ScriptClass]..') of '..ScriptClass..' is available!')
--install update?
installUpdate()
end
else
error(res)
end
end)
end
function installUpdate()
print('[33ff33]Installing Upgrade to '..ScriptClass..'[-]')
WebRequest.get('yourgithubfile.lua', function(res)
if (not(res.is_error)) then
self.setLuaScript(res.text)
self.reload()
print('[33ff33]Installation Successful[-]')
else
error(res)
end
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment