Last active
May 2, 2019 16:50
-
-
Save RobMayer/5e39c825dca03541a9f2a72ce1cb9e18 to your computer and use it in GitHub Desktop.
[TTS] Auto-Update utility
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
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