Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function writeFile(dir,data)
- local file = fs.open(dir, "w")
- file.write(data)
- file.close()
- return true
- end
- function readFile(dir)
- if fs.exists(dir) then
- local file = fs.open(dir,"r")
- local fileData = file.readAll()
- file.close()
- return fileData, true
- else
- return false
- end
- end
- function update(pastebin,dir)
- resp = http.get("https://pastebin.com/raw/" .. pastebin)
- if resp then
- resp = resp.readAll()
- curFile = readFile(dir)
- if(resp ~= curFile) then
- local succes = writeFile(dir)
- if(succes == true) then
- print("Updated program!")
- error()
- else
- print("Couldn't update, proceeding to run old version...")
- end
- end
- end
- end
- update("q2SAhS22", shell.getRunningProgram())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement