Advertisement
nik1111

version

May 19th, 2022
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. local GUI_API_VERSION = "1.0.0"
  2. local GUI_API_CDN_URL = "https://cdn.grcpils.fr/cc-files/GUI_API/"
  3. local GUI_API_VERSION_FILE = "version.lua"
  4. local GUI_API_DIRECTORY = "GUI"
  5. local GUI_API_DIRECTORY_TEMP = "GUI/tmp"
  6. local Utils = require("GUI/utils")
  7.  
  8. local download = function(url, file)
  9. local content = http.get(url).readAll()
  10. if not content then
  11. error("Could not connect to website")
  12. end
  13. f = fs.open(file, "w")
  14. f.write(content)
  15. f.close()
  16. end
  17.  
  18. local get = function ()
  19. return GUI_API_VERSION
  20. end
  21.  
  22. local checkUpdate = function ()
  23. download(GUI_API_CDN_URL.."version.lua", GUI_API_DIRECTORY_TEMP.."/version.lua")
  24. local version = require(GUI_API_DIRECTORY.."/version")
  25. local nversion = require(GUI_API_DIRECTORY_TEMP.."/version")
  26. if version.get() ~= nversion.get() then
  27. Utils.printWarn("[GUI] New version of GUI is available !\n")
  28. end
  29. fs.delete(GUI_API_DIRECTORY_TEMP)
  30. end
  31.  
  32. return { get = get, checkUpdate = checkUpdate }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement