Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local FILENAME = '/test.lua'
- local internet = require("internet")
- local cacheBreak = tostring(math.random(0, 99999))
- local response = internet.request('https://raw.githubusercontent.com/MrRiptide/OpenComputers/master/test.lua?breaker=' .. cacheBreak)
- local code = ""
- for chunk in response do
- code = code .. chunk
- end
- if not(filesystem.exists(FILENAME))
- then
- local newHarvest = io.open(FILENAME, 'w')
- newHarvest:close()
- end
- local readFile = io.open(FILENAME, 'r')
- local oldCode = readFile:read("*a")
- readFile:close()
- local file = io.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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement