Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local module = {}
- module.getRemoteData = function (id)
- local file = http.get("http://pastebin.com/raw.php?i=" .. id)
- if file then
- local data = httpResponce.readAll()
- httpResponce.close()
- return data
- else
- error('No file with id "'..id..'" found')
- end
- end
- module.getLocalData = function (name)
- local file = fs.open(name, "r")
- local data = file.readAll()
- file.close()
- return data
- end
- module.getVersion = function (data)
- local _, versionIndex = string.find(data, 'K_VERSION *= *')
- if (versionIndex) then return tonumber(string.match(data, '%d+[%.?%d*]*', versionIndex + 1))
- else return 0 end
- end
- module.run = function ()
- local id = 'QKPAfPkU'
- local name = 'startup'
- local remoteVersion = getVersion(getRemoteData(id))
- local localVersion = getVersion(getLocalData(name))
- print(remoteVersion, localVersion)
- end
- return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement