Computercraft thingies
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

install.lua 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. local base = "http://s.mort.coffee/mortcc"
  2. local files = {
  3. bin = {
  4. "floor.lua";
  5. "ls.lua";
  6. "help.lua";
  7. "man.lua";
  8. "craft.lua";
  9. "guitest.lua";
  10. },
  11. manpages = {
  12. "floor";
  13. "ls";
  14. "help";
  15. "man";
  16. "craft";
  17. },
  18. lib = {
  19. mturtle = "mturtle.lua";
  20. util = "util.lua";
  21. program = "program.lua";
  22. graphics = "graphics.lua";
  23. },
  24. run = "run.lua";
  25. update = "update.lua";
  26. }
  27. function download(src, dst)
  28. local url = base .. src
  29. print("Downloading")
  30. print(url)
  31. local ok, err = http.checkURL(url)
  32. if not ok then
  33. print(err)
  34. return
  35. end
  36. local h = http.get(url)
  37. if h == nil then
  38. print("Invalid URL.")
  39. return
  40. end
  41. local f = fs.open(dst, "w")
  42. f.write(h.readAll())
  43. f.close()
  44. end
  45. function mkfiles(dir, path)
  46. for key, val in pairs(dir) do
  47. if type(key) == "number" then
  48. local p = path .. "/" .. val
  49. download(p, p)
  50. elseif type(val) == "string" then
  51. local src = path .. "/" .. val
  52. local dst = path .. "/" .. key
  53. download(src, dst)
  54. else
  55. local p = path .. "/" .. key
  56. fs.makeDir(p)
  57. mkfiles(dir[key], p)
  58. end
  59. end
  60. end
  61. mkfiles(files, "")