Advertisement
RadioNurshat

Shopping Program Installer

Feb 26th, 2017
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. local component = require("component")
  2. local unicode = require("unicode")
  3. local fs = require("filesystem")
  4. local gpu = component.gpu
  5.  
  6. local applications = {
  7. { url = "https://raw.githubusercontent.com/RadioNurshat/Luaproject/master/NEECSAPI.lua", path = "/lib/NEECSAPI.lua" },
  8. { url = "https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/ECSAPI.lua", path = "/lib/ECSAPI.lua" },
  9. { url = "https://raw.githubusercontent.com/RadioNurshat/Luaproject/master/Shop/JSON.lua", path = "/lib/JSON.lua" },
  10. { url = "https://raw.githubusercontent.com/RadioNurshat/Luaproject/master/Shop/shopcount.json", path = "/Shop/shopcount.json" },
  11. { url = "https://raw.githubusercontent.com/RadioNurshat/Luaproject/master/Shop/Заказы/gs.config", path = "/Заказы/gs.config" },
  12. { url = "https://raw.githubusercontent.com/RadioNurshat/Luaproject/master/Shopping program v2.lua", path = "/RNShop.lua" },
  13. }
  14.  
  15. function getFile(url, path)
  16. local file = io.open(path, "w")
  17.  
  18. local pcallSuccess, requestHandle, requestReason = pcall(component.internet.request, url)
  19. if pcallSuccess then
  20. if requestHandle then
  21. while true do
  22. local data, reason = requestHandle.read(math.huge)
  23. if data then
  24. file:write(data)
  25. else
  26. requestHandle:close()
  27. if reason then
  28. error(reason)
  29. else
  30. file:close()
  31. return
  32. end
  33. end
  34. end
  35. else
  36. errro("Invalid URL addess")
  37. end
  38. else
  39. error("Usage: component.internet.request(string url)")
  40. end
  41.  
  42. file:close()
  43. end
  44.  
  45. --Программа
  46. for i = 1, #applications do
  47. getFile(applications[i].url, applications[i].path)
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement