Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------=WARNING=------
- --Just a quick warning, this MAY NOT WORK IN ITS CURRENT STATE. I am unable to test it at this exact moment. Thanks!
- ------=WARNING=------
- --Program Updater API Thingy! Yay!
- --This script basically just updates any pastebin program as an API :)
- --It could probably be MUCH better. So, yeah. Fun. ANYWAYS...
- -------IMPORTANT-------
- --Put this little snippet of code in your program that needs auto-updating!
- --version = *version* --(only one decimal point may be used. Commas are NOT to be used!)
- --function returnVersionAPI()
- -- return version
- --end
- -------IMPORTANT-------
- -------NOTE-------
- --The functions are written in cronological order of which you should run them!
- -------NOTE-------
- -------NOTE2-------
- --Your Version List MUST have this bit of code for a sort of API!
- --=--function getVersion(programName)
- --=--return programName
- --=--end
- --This basically lets my API intrface your version list. You send my API (for example) "remoteVersion(exampleProgramName)" then your
- --version list sends back the version the variable has. So say exampleProgramName's version was 1. Your version list would send back 1,
- --as a number. IT MUST BE A NUMBER, NOT A STRING!
- -------NOTE2-------
- function findVersionList(versionListName)
- if fs.exists(versionListName) then
- shell.run("delete ".. versionListName)
- end
- ---------------
- function grabTheVersionList(pastebinCode,versionListName)
- shell.run("pastebin get ".. pastebinCode .." ".. versionListName)
- end
- ---------------
- function remoteVerison(versionListName,programName)
- os.loadAPI(versionListName)
- newVersion = versionlist.getVersion(programName)
- if newVersion not nul then
- return newVersion
- shell.run("delete ".. versionListName)
- else
- return false
- end
- end
- ---------------
- function findTheProgramVersion(programName)
- if fs.exists(programName) then
- os.loadAPI(programName)
- dledVersion = programName.returnVersionAPI()
- if dledVersion not nul then
- return dledVersion
- else
- return false
- end
- end
- end
- ---------------
- function update(dledVersion,newVersion,programName) --This actually updates.
- if dledVersion < newVersion then
- shell.run("delete ".. programName)
- shell.run("pastebin get suVzDDJG".. programName)
- print("Updated from version ".. dledVerison .." to ".. newVerison .."!")
- return "updated"
- elseif dledVersion == newVersion then
- print("You are up to date!")
- return "up to date"
- elseif dledVersion > newVersion then
- print("Somebody forgot to update their version list!")
- return "beta version?"
- end
- end
- -------EXAMPLE-------
- --This example actually updates the updater... makes TOTAL sense, right? :P
- --version = 1
- os.loadAPI("updater")
- updater.findVersionList("versionlist")
- updater.grabTheVersionList("HmZ3GzVv","versionList")
- remoteVersion = updater.remoteVersion(AutoUpdater)
- dledVersion = updater.findTheProgramVersion("updater")
- updater.update(dledVersion,remoteVersion,updater)
- -------EXAMPLE-------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement