Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- version = 7
- function download(sCode, sFile, bCheckVer)
- sPath = shell.resolve( sFile )
- if fs.exists( sPath ) then
- fs.delete( sPath )
- end
- local response = http.get(
- "http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode )
- )
- if response then
- local sResponse = response.readAll()
- response.close()
- local file = fs.open( sPath, "w" )
- file.write( sResponse )
- file.close()
- vers = nil
- if bCheckVer then
- file = fs.open(sFile, "r")
- vers = string.sub(file.readLine(), 11,11)
- file.close()
- fs.delete(sFile)
- end
- return tonumber( vers )
- else
- print( "Failed." )
- end
- end
- print("Oi, MEKIE!")
- newversion = download("tSkz5fWh", "ver", true)
- print("Current version: "..version)
- print("Version available: "..newversion)
- if version < newversion then
- print("New version available")
- print("Update? (y/n): ")
- conf = read()
- if conf == "y" then
- download("tSkz5fWh", shell.getRunningProgram(), false)
- else
- return
- end
- else
- print("No update available")
- end
Advertisement
Add Comment
Please, Sign In to add comment