Advertisement
DaikiKaminari

installer_temp

Apr 10th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. -- delete files
  2. local function removeFiles(files)
  3. for _,f in ipairs(files) do
  4. if fs.exists(f) then
  5. shell.run("rm " .. f)
  6. end
  7. end
  8. end
  9.  
  10. -- save the content of an HTTP link into a file
  11. local function HTTPSaveToFile(link, filename)
  12. local h = fs.open(filename, "w")
  13. local http = http.get(link)
  14. if http == nil then
  15. error("Cannot get http object from link :\n" .. link)
  16. end
  17. local str = http.readAll()
  18. if str == "" or str == nil then
  19. error("Cannot get text from http object")
  20. end
  21. h.writeLine(str)
  22. h.close()
  23. end
  24.  
  25. removeFiles({"lib/item", "lib/objectJSON", "config", "recipesManager", "startup"})
  26. HTTPSaveToFile("https://gitlab.com/computercraftdaiki/bloodmagic/-/raw/master/lib/item.lua", "lib/item")
  27. HTTPSaveToFile("https://gitlab.com/computercraftdaiki/bloodmagic/-/raw/master/lib/objectJSON.lua", "lib/objectJSON")
  28. HTTPSaveToFile("https://gitlab.com/computercraftdaiki/bloodmagic/-/raw/master/config.json", "config")
  29. HTTPSaveToFile("https://gitlab.com/computercraftdaiki/bloodmagic/-/raw/master/recipesManager.lua", "recipesManager")
  30. HTTPSaveToFile("https://gitlab.com/computercraftdaiki/bloodmagic/-/raw/master/main.lua", "startup")
  31. shell.run("startup")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement