Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gistID = 'f404711feaaa8328f7f7110f40c6136b'
- local FILENAME = '/test.lua'
- local cacheBreak = tostring(math.random(0, 99999))
- local link = 'https://gist.githubusercontent.com/PatrickScharberg/' .. gistID .. '/raw/' .. cacheBreak
- res, err = http.get(link)
- if not res then error(err) end
- local code = res.readAll()
- if not(fs.exists(FILENAME))
- then
- local newHarvest = fs.open(FILENAME, 'w')
- newHarvest.close()
- end
- local readFile = fs.open(FILENAME, 'r')
- local oldCode = readFile.readAll()
- readFile.close()
- local file = fs.open(FILENAME, 'w')
- if oldCode == code
- then
- file.write(oldCode)
- print('NO CHANGES MADE - Same Code')
- else
- file.write(code)
- print('WRITING UPDATE')
- byteDiff = string.len(code) - string.len(oldCode)
- if byteDiff >= 0
- then
- print(tostring(math.abs(byteDiff)) .. ' bytes added')
- else
- print(tostring(math.abs(byteDiff)) .. ' bytes removed')
- end
- end
- file.close()
- res.close()
- shell.run(FILENAME)
Add Comment
Please, Sign In to add comment