Advertisement
Sparta252

Tinker's calculator installer

Jun 14th, 2024 (edited)
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. local function downloadFile(url, filename)
  2.     local response = http.get(url)
  3.     if response then
  4.         local file = fs.open("tinkers/"..filename, "w")
  5.         file.write(response.readAll())
  6.         file.close()
  7.         response.close()
  8.         print("Soubor ".. filename .." bol uspesne stiahnuty.")
  9.     else
  10.         print("Nepodarilo se stiahnut soubor z danej URL.")
  11.     end
  12. end
  13.  
  14.  
  15. local url = "https://raw.githubusercontent.com/Sparta252/tinkers_calculator/main/tinkers/calc.lua"
  16. downloadFile(url, "calc.lua")
  17. url = "https://raw.githubusercontent.com/Sparta252/tinkers_calculator/main/tinkers/data.lua"
  18. downloadFile(url, "data.lua")
  19.  
  20. local folder = "tinkers"
  21. if not fs.exists(folder.."/whitelist.lua") then
  22.     local file = fs.open(folder.."/whitelist.lua", "w")
  23.     file.close()
  24. end
  25. if not fs.exists(folder.."/blacklist.lua") then
  26.     local file = fs.open(folder.."/blacklist.lua", "w")
  27.     file.close()
  28. end
  29. if not fs.exists("tinkers/materials") then
  30.     fs.makeDir("tinkers/materials")
  31. end
  32.  
  33. print("Chete stiahnut aj databazu ? [Y/N]")
  34. local input = read()
  35. if input == "Y" then
  36.     print("Stahujem Databazu")
  37.     sleep(2.5)
  38.     local database = fs.open("tinkers/data.lua", "r")
  39.     while 1 do
  40.         local material = database.readLine()
  41.         if not material then
  42.             break
  43.         end
  44.         url = "https://raw.githubusercontent.com/Sparta252/tinkers_calculator/main/tinkers/materials/"..material
  45.         downloadFile(url, "materials/"..material)
  46.  
  47.     end
  48.     database.close()
  49. else
  50.     print("Databaza sa nestahuje.")
  51. end
  52.  
  53. print("hotovo")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement