Advertisement
DaikiKaminari

checkVersion

Apr 27th, 2020
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. if not fs.exists("github") then
  2.     shell.run("pastebin get fneHBM66 github")
  3. end
  4.  
  5. if not fs.exists("lib/objectJSON") or not fs.exists("lib/json") then
  6.     error("objectJSON or json does not exist.")
  7. end
  8. os.loadAPI("lib/objectJSON")
  9. objectJSON.init()
  10.  
  11. local version = objectJSON.decodeFromFile("version").version
  12. print("Actual version : " .. tostring(version))
  13. local newVersion
  14. while true do
  15.     newVersion = objectJSON.decodeHTTP("https://raw.githubusercontent.com/DaikiKaminari/thaumcraft/master/version").version
  16.     if newVersion ~= nil and version ~= newVersion then
  17.         print("New version :" .. tostring(newVersion))
  18.         for _,f in pairs(fs.list("downloads/thaumcraft")) do
  19.             shell.run("rm " .. f)
  20.         end
  21.         shell.run("github DaikiKaminari thaumcraft")
  22.         shell.run("cp downloads/thaumcraft/* .")
  23.         return
  24.     end
  25.     sleep(1)
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement