Thomasims

Untitled

Mar 9th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.31 KB | None | 0 0
  1. local source = "http://geeksmod.net/ccos/content"
  2.  
  3. print("Fetching manifest from "..source)
  4.  
  5. local lnk = http.get(source)
  6.  
  7. if not lnk then
  8.     error("Source is dead")
  9. end
  10.  
  11. local contents = textutils.unserialize(lnk.readAll())
  12. lnk.close()
  13.  
  14. local baseurl = contents.base
  15.  
  16. print("Getting required files...")
  17.  
  18. for i=1,#contents.required do
  19.     local f = contents.required[i]
  20.     print("Getting "..f)
  21.     for j=1,#f do
  22.         if f:sub(j,j)=="/" then
  23.             local found = f:sub(1,j-1)
  24.             if not fs.exists(found) then
  25.                 fs.makeDir(found)
  26.             end
  27.         end
  28.     end
  29.     if f:sub(-1)~="/" then
  30.         local file = fs.open(f,"w")
  31.         local content = http.get(baseurl..f).readAll()
  32.         file.write(content)
  33.         file.close()
  34.     end
  35. end
  36. print("Done downloading required files")
  37.  
  38. -------------------------------------------------------------------------
  39. --                       MODULE SELECTION MENU                         --
  40. -------------------------------------------------------------------------
  41.  
  42. local w,h = term.getSize()
  43. local mid = math.floor(w/2)
  44. local disp = h-5
  45. local dispw = mid-3
  46.  
  47. local panel1 = {tab = {}, off = 0, selected = 0}
  48. local panel2 = {tab = {}, off = 0, selected = 0}
  49.  
  50. local function hasn(tab,name)
  51.     for k,v in pairs(tab) do if v.name==name then return true end end
  52.     return false
  53. end
  54.  
  55. -----------
  56. --PRESETS--
  57. -----------
  58.  
  59. if contents.presets then
  60.     print("Presets are available: ")
  61.     local k=1
  62.     for i,preset in ipairs(contents.presets) do
  63.         k=k+1
  64.         term.setTextColor(colors.green)
  65.         print(""..i..": "..preset.name..":")
  66.         term.setTextColor(colors.orange)
  67.         print("    ->"..preset.desc)
  68.     end
  69.     term.setTextColor(colors.green)
  70.     print(""..k..": Manual Config")
  71.     term.setTextColor(colors.white)
  72.     term.write("Mode > ")
  73.     local c = read()
  74.     local cn = tonumber(c)
  75.     if cn then
  76.         if cn>0 and cn<k and math.floor(cn)==cn then --select preset
  77.             for id,modn in ipairs(contents.presets[cn].modules) do
  78.                 panel2.tab[#panel2.tab+1] = {name=modn}
  79.             end
  80.         end
  81.     end
  82. end
  83.  
  84. ----------
  85. --MANUAL--
  86. ----------
  87. local si = #panel2.tab==0
  88. local prevmods = {}
  89. if fs.exists(".installed_modules") then
  90.     local f = fs.open(".installed_modules","r")
  91.     local mods = textutils.unserialize(f.readAll())
  92.     f.close()
  93.     for i,m in ipairs(mods) do
  94.         if si then
  95.             table.insert(panel2.tab,m)
  96.         end
  97.         table.insert(prevmods,m)
  98.     end
  99. end
  100.  
  101. if si then
  102. ---
  103.  
  104.  
  105. for i=1,#contents.modules do
  106.     if not hasn(panel2.tab,contents.modules[i].name) then
  107.         table.insert(panel1.tab,{
  108.             name = contents.modules[i].name,
  109.             file = contents.modules[i].file,
  110.             conflict = contents.modules[i].conflict,
  111.             require = contents.modules[i].required
  112.         })
  113.     end
  114. end
  115.  
  116. local dirty = true
  117. local p1d = true
  118. local p2d = true
  119. local md = true
  120.  
  121. local popup = nil
  122.  
  123. local function slice(txt,len)
  124.     local t = {}
  125.     local added = 0
  126.     for i = 1,#txt,len do
  127.         local max=added+len
  128.         while txt:sub(max,max)~=" " and max>1 and added+max<#txt do
  129.             max=max-1
  130.         end
  131.         t[#t+1] = txt:sub(added+1,added+max)
  132.         added=added+max
  133.     end
  134.     return t
  135. end
  136.  
  137. local function redraw()
  138.     if not dirty then return end
  139.     dirty = false
  140.  
  141.     if popup then
  142.         paintutils.drawFilledBox(2,h/2-popup.h/2-1,3+popup.w,h/2+popup.h/2,colors.blue)
  143.         paintutils.drawFilledBox(3,h/2-popup.h/2,2+popup.w,h/2+popup.h/2-1,colors.white)
  144.         for i=1,#popup.els do
  145.             local e = popup.els[i]
  146.             if e and type(e)=="table" and #e>4 then
  147.                 term.setTextColor(e[3])
  148.                 term.setBackgroundColor(e[4])
  149.                 local txt = slice(e[5],popup.w)
  150.                 for i=1,#txt do
  151.                     term.setCursorPos(1+e[1], h/2-popup.h/2-2+e[2]+i)
  152.                     term.write(txt[i])
  153.                 end
  154.             end
  155.         end
  156.         return
  157.     end
  158.  
  159.     if md then
  160.         md=false
  161.         term.clear()
  162.         paintutils.drawFilledBox(1,1,w,1,colors.gray)
  163.         term.setCursorPos(1,1)
  164.         term.setTextColor(colors.black)
  165.         term.write("Modules selection")
  166.         paintutils.drawFilledBox(1,2,w,h,colors.white)
  167.         paintutils.drawFilledBox(2,3,mid-1,h-3,colors.gray)
  168.         term.setCursorPos(mid-1,3)
  169.         term.setBackgroundColor(colors.red)
  170.         term.write("^")
  171.         term.setCursorPos(mid-1,h-3)
  172.         term.setBackgroundColor(colors.red)
  173.         term.write("V")
  174.         paintutils.drawFilledBox(mid-1,4,mid-1,h-4,colors.black)
  175.         paintutils.drawFilledBox(mid+2,3,w-1,h-3,colors.gray)
  176.         term.setCursorPos(w-1,3)
  177.         term.setBackgroundColor(colors.red)
  178.         term.write("^")
  179.         term.setCursorPos(w-1,h-3)
  180.         term.setBackgroundColor(colors.red)
  181.         term.write("V")
  182.         paintutils.drawFilledBox(w-1,4,w-1,h-4,colors.black)
  183.         term.setCursorPos(mid,h/2)
  184.         term.setBackgroundColor(colors.lightGray)
  185.         term.write(">")
  186.         term.setCursorPos(mid,h/2+2)
  187.         term.setBackgroundColor(colors.lightGray)
  188.         term.write("<")
  189.         term.setCursorPos(w-9, h-1)
  190.         term.write(" Confirm ")
  191.     end
  192.    
  193.     if p1d then
  194.         p1d=false
  195.         local hi=3
  196.         local size = math.min(1,disp/#panel1.tab)
  197.         local c = 0
  198.         for i=1+panel1.off,math.min(#panel1.tab,panel1.off+disp) do
  199.             local l = panel1.tab[i]
  200.             term.setCursorPos(2,hi)
  201.             if i==panel1.selected or (type(panel1.selected)=="table" and panel1.selected[i]) then
  202.             term.setBackgroundColor(colors.lightGray)
  203.             else
  204.             term.setBackgroundColor(colors.gray)
  205.             end
  206.             term.setTextColor(colors.black)
  207.             term.write(l.name:sub(1,dispw)..string.rep(" ",dispw-#l.name))
  208.             hi=hi+1
  209.             c=c+1
  210.         end
  211.         if c<disp then
  212.             paintutils.drawFilledBox(2,3+c,mid-2,h-3,colors.gray)
  213.         end
  214.         if panel1.tab[panel1.selected] or type(panel1.selected)=="table" then
  215.             term.setCursorPos(mid,h/2)
  216.             term.setBackgroundColor(colors.lime)
  217.             term.write(">")
  218.         else
  219.             term.setCursorPos(mid,h/2)
  220.             term.setBackgroundColor(colors.lightGray)
  221.             term.write(">")
  222.         end
  223.     end
  224.    
  225.     if p2d then
  226.         p2d=false
  227.         local hi=3
  228.         local size = math.min(1,disp/#panel2.tab)
  229.         local c = 0
  230.         for i=1+panel2.off,math.min(#panel2.tab,panel2.off+disp) do
  231.             local l = panel2.tab[i]
  232.             term.setCursorPos(mid+2,hi)
  233.             if i==panel2.selected or (type(panel2.selected)=="table" and panel2.selected[i]) then
  234.                 term.setBackgroundColor(colors.lightGray)
  235.             else
  236.                 term.setBackgroundColor(colors.gray)
  237.             end
  238.             term.setTextColor(colors.black)
  239.             term.write(l.name:sub(1,dispw)..string.rep(" ",dispw-#l.name))
  240.             if l.warnings and #l.warnings>0 then
  241.                 if panel2.selerr and panel2.selerr.tp==2 and panel2.selerr.id==i then
  242.                     for k=1,#l.warnings do
  243.                         term.setCursorPos(w-4-#l.warnings[k],hi+k-1)
  244.                         term.setBackgroundColor(colors.yellow)
  245.                         term.setTextColor(colors.black)
  246.                         term.write(l.warnings[k].."<")
  247.                     end
  248.                     c=c+#l.warnings-1
  249.                 else
  250.                     term.setCursorPos(w-4,hi)
  251.                     term.setBackgroundColor(colors.yellow)
  252.                     term.setTextColor(colors.black)
  253.                     term.write("!")
  254.                 end
  255.             end
  256.             if l.problems and #l.problems>0 then
  257.                 if panel2.selerr and panel2.selerr.tp==1 and panel2.selerr.id==i then
  258.                     for k=1,#l.problems do
  259.                         term.setCursorPos(w-3-#l.problems[k],hi+k-1)
  260.                         term.setBackgroundColor(colors.red)
  261.                         term.setTextColor(colors.white)
  262.                         term.write(l.problems[k].."<")
  263.                     end
  264.                     c=c+#l.problems-1
  265.                 else
  266.                     term.setCursorPos(w-3,hi)
  267.                     term.setBackgroundColor(colors.red)
  268.                     term.setTextColor(colors.white)
  269.                     term.write("!")
  270.                 end
  271.             end
  272.             hi=hi+1
  273.             c=c+1
  274.         end
  275.         if c<disp then
  276.             paintutils.drawFilledBox(mid+2,3+c,w-2,h-3,colors.gray)
  277.         end
  278.         if panel2.tab[panel2.selected] or type(panel2.selected)=="table" then
  279.             term.setCursorPos(mid,h/2+2)
  280.             term.setBackgroundColor(colors.lime)
  281.             term.write("<")
  282.         else
  283.             term.setCursorPos(mid,h/2+2)
  284.             term.setBackgroundColor(colors.lightGray)
  285.             term.write("<")
  286.         end
  287.     end
  288.    
  289. end
  290.  
  291. local doloop = true
  292.  
  293. local controld = false
  294. local shiftd = false
  295. local lastsel = nil
  296.  
  297. while doloop do
  298.     redraw()
  299.     local e = {os.pullEvent()}
  300.     if popup then
  301.         if e[1]=="mouse_click" and e[2]==1 then
  302.             local clk,x,y = e[2],e[3],e[4]
  303.             for i=1,#popup.els do
  304.                 local e = popup.els[i]
  305.                 if type(e)=="table" and type(e[6])=="function" then
  306.                     if x>=math.floor(e[1]+1) and x<math.floor(e[1]+#e[5]+1) and y==e[2]+math.floor(h/2-popup.h/2-1) then
  307.                         e[6]()
  308.                         break
  309.                     end
  310.                 end
  311.             end
  312.         end
  313.     else
  314.         if e[1]=="key" then
  315.             local key = e[2]
  316.             if key==208 then --down
  317.             end
  318.             if key==200 then --up
  319.             end
  320.             if key==29 then --control
  321.                 controld = true
  322.             end
  323.             if key==42 then --shift
  324.                 shiftd = true
  325.             end
  326.         end
  327.         if e[1]=="key_up" then
  328.             local key = e[2]
  329.             if key==29 then --control
  330.                 controld = false
  331.             end
  332.             if key==42 then --shift
  333.                 shiftd = false
  334.             end
  335.         end
  336.         if e[1]=="mouse_click" then
  337.             local clk,x,y = e[2],e[3],e[4]
  338.             if clk==1 then
  339.                 --Confirm
  340.                 if x>w-10 and x<w and y==h-1 then
  341.                     local haserr = false
  342.                     local haswarn = false
  343.  
  344.                     for i=1,#panel2.tab do
  345.                         local t = panel2.tab[i]
  346.                         if t.problems and #t.problems>0 then haserr=true end
  347.                         if t.warnings and #t.warnings>0 then haswarn=true end
  348.                     end
  349.  
  350.                     local pw = w-4
  351.                     local txt1 = haserr and "Some modules are conflicting, they may cause issues." or ""
  352.                     local txt2 = haswarn and "Some required modules are not selected, they will be downloaded." or ""
  353.                     local ln1 = (haserr and math.floor(#txt1/(pw-2)+1) or 0)
  354.                     local ln2 = (haswarn and math.floor(#txt2/(pw-2)+1) or 0)
  355.                     local ph = 3 + ln1 + ln2
  356.                     if haserr or haswarn then ph=ph+1 end
  357.                     popup = {
  358.                         w = pw,
  359.                         h = ph,
  360.                         els = {
  361.                             {pw/2-1,1,colors.black,colors.white, "Confirm"},
  362.                             (haserr and {2,3,colors.red,colors.white,txt1} or 0),
  363.                             (haswarn and {2,(ph-ln2)-1,colors.yellow,colors.white,txt2} or 0),
  364.                             {3,ph,colors.black,colors.red,"Cancel",function()
  365.                                 popup=nil dirty=true p1d=true p2d=true md=true
  366.                             end},{pw-1,ph,colors.black,colors.lime,"Ok",function()
  367.                                 popup = nil
  368.                                 doloop = false
  369.                                 --Finish config
  370.                             end}
  371.                         }
  372.                     }
  373.                     dirty=true
  374.                 end
  375.                 --Panel 1
  376.                 if x==mid-1 and y==3 then
  377.                     panel1.off = math.max(0,panel1.off-1)
  378.                     dirty = true
  379.                     p1d=true
  380.                 end
  381.                 if x==mid-1 and y==h-3 then
  382.                     panel1.off = math.min(math.max(#panel1.tab-disp,0),panel1.off+1)
  383.                     dirty = true
  384.                     p1d=true
  385.                 end
  386.                 if x<mid-1 and x>1 and y>2 and y<h-2 then
  387.                     if shiftd then
  388.                         local base = panel1.lastsel or 1
  389.                         if panel1.tab[y-2+panel1.off] then
  390.                             panel1.selected = {}
  391.                             for i = base,y-2+panel1.off,(y-2+panel1.off<base) and -1 or 1 do
  392.                                 panel1.selected[i] = true
  393.                             end
  394.                         end
  395.                     elseif controld then
  396.                         if type(panel1.selected)=="number" and panel1.tab[panel1.selected] then
  397.                             local al = panel1.selected
  398.                             panel1.selected = {}
  399.                             panel1.selected[al] = true
  400.                             if panel1.tab[y-2+panel1.off] then
  401.                                 panel1.selected[y-2+panel1.off] = true
  402.                             end
  403.                         elseif type(panel1.selected)=="table" then
  404.                             if panel1.tab[y-2+panel1.off] then
  405.                                 panel1.selected[y-2+panel1.off] = true
  406.                             end
  407.                         else
  408.                             panel1.selected = y-2+panel1.off
  409.                         end
  410.                     else
  411.                         panel1.selected = y-2+panel1.off
  412.                     end
  413.                     if panel1.tab[y-2+panel1.off] then
  414.                         panel1.lastsel=y-2+panel1.off
  415.                     end
  416.                     panel2.selected = 0
  417.                     panel2.lastsel = nil
  418.                     dirty = true
  419.                     p1d=true
  420.                     p2d=true
  421.                 end
  422.                
  423.                 --Panel 2
  424.                 if x==w-1 and y==3 then
  425.                     panel2.off = math.max(0,panel2.off-1)
  426.                     dirty = true
  427.                     p2d=true
  428.                 end
  429.                 if x==w-1 and y==h-3 then
  430.                     panel2.off = math.min(math.max(#panel2.tab-disp,0),panel2.off+1)
  431.                     dirty = true
  432.                     p2d=true
  433.                 end
  434.                 if x==w-3 then
  435.                     local opt = y-2+panel2.off
  436.                     if panel2.tab[opt] and panel2.tab[opt] then
  437.                         panel2.selerr = {tp=1,id=opt}
  438.                         dirty = true
  439.                         p2d=true
  440.                     end
  441.                 elseif x==w-4 then
  442.                     local opt = y-2+panel2.off
  443.                     if panel2.tab[opt] and panel2.tab[opt] then
  444.                         panel2.selerr = {tp=2,id=opt}
  445.                         dirty = true
  446.                         p2d=true
  447.                     end
  448.                 elseif panel2.selerr~=nil then
  449.                     panel2.selerr=nil
  450.                     dirty = true
  451.                     p2d=true
  452.                 end
  453.                 if x<w-1 and x>mid+1 and y>2 and y<h-2 then
  454.                     if shiftd then
  455.                         local base = panel2.lastsel or 1
  456.                         if panel2.tab[y-2+panel2.off] then
  457.                             panel2.selected = {}
  458.                             for i = base,y-2+panel2.off,(y-2+panel2.off<base) and -1 or 1 do
  459.                                 panel2.selected[i] = true
  460.                             end
  461.                         end
  462.                     elseif controld then
  463.                         if type(panel2.selected)=="number" and panel2.tab[panel2.selected] then
  464.                             local al = panel2.selected
  465.                             panel2.selected = {}
  466.                             panel2.selected[al] = true
  467.                             if panel2.tab[y-2+panel2.off] then
  468.                                 panel2.selected[y-2+panel2.off] = true
  469.                             end
  470.                         elseif type(panel2.selected)=="table" then
  471.                             if panel2.tab[y-2+panel2.off] then
  472.                                 panel2.selected[y-2+panel2.off] = true
  473.                             end
  474.                         else
  475.                             panel2.selected = y-2+panel1.off
  476.                         end
  477.                     else
  478.                         panel2.selected = y-2+panel2.off
  479.                     end
  480.                     if panel2.tab[y-2+panel2.off] then
  481.                         panel2.lastsel=y-2+panel2.off
  482.                     end
  483.                     panel1.selected = 0
  484.                     panel1.lastsel = nil
  485.                     dirty = true
  486.                     p2d=true
  487.                     p1d=true
  488.                 end
  489.                
  490.                 if x==mid and y==math.floor(h/2) then
  491.                     if type(panel1.selected)=="number" then
  492.                         local data = panel1.tab[panel1.selected]
  493.                         if data then
  494.                             table.remove(panel1.tab,panel1.selected)
  495.                             table.insert(panel2.tab,data)
  496.                             panel2.selected = 0
  497.                             panel1.selected = 0
  498.                             dirty = true
  499.                             p2d=true
  500.                             p1d=true
  501.                         end
  502.                     elseif type(panel1.selected)=="table" then
  503.                         local before,remd = #panel1.tab,0
  504.                         for i,_ in pairs(panel1.selected) do
  505.                             remd=remd+1
  506.                             local data = panel1.tab[i]
  507.                             panel1.tab[i] = nil
  508.                             table.insert(panel2.tab,data)
  509.                         end
  510.                         local add=0
  511.                         for i=1,before-remd do
  512.                             while not panel1.tab[i+add] do add=add+1 end
  513.                             panel1.tab[i] = panel1.tab[i+add]
  514.                         end
  515.                         for i=before-remd+1,before do panel1.tab[i]=nil end
  516.                         panel2.selected = 0
  517.                         panel1.selected = 0
  518.                         panel1.lastsel = nil
  519.                         panel2.lastsel = nil
  520.                         dirty = true
  521.                         p2d=true
  522.                         p1d=true
  523.                     end
  524.                 end
  525.                 if x==mid and y==math.floor(h/2+2) then
  526.                     if type(panel2.selected)=="number" then
  527.                         local data = panel2.tab[panel2.selected]
  528.                         if data then
  529.                             table.remove(panel2.tab,panel2.selected)
  530.                             table.insert(panel1.tab,data)
  531.                             panel1.selected = 0
  532.                             panel2.selected = 0
  533.                             dirty = true
  534.                             p2d=true
  535.                             p1d=true
  536.                         end
  537.                     elseif type(panel2.selected)=="table" then
  538.                         local before,remd = #panel2.tab,0
  539.                         for i,_ in pairs(panel2.selected) do
  540.                             remd=remd+1
  541.                             local data = panel2.tab[i]
  542.                             panel2.tab[i] = nil
  543.                             table.insert(panel1.tab,data)
  544.                         end
  545.                         local add=0
  546.                         for i=1,before-remd do
  547.                             while not panel2.tab[i+add] do add=add+1 end
  548.                             panel2.tab[i] = panel2.tab[i+add]
  549.                         end
  550.                         for i=before-remd,before do panel2.tab[i]=nil end
  551.                         panel1.selected = 0
  552.                         panel2.selected = 0
  553.                         panel1.lastsel = nil
  554.                         panel2.lastsel = nil
  555.                         dirty = true
  556.                         p2d=true
  557.                         p1d=true
  558.                     end
  559.                 end
  560.             end
  561.         end
  562.         if e[1]=="mouse_scroll" then
  563.             local dir,x,y = e[2],e[3],e[4]
  564.             if x<mid and x>1 and y>2 and y<h-2 then
  565.                 if dir==-1 then
  566.                     panel1.off = math.max(0,panel1.off-1)
  567.                     dirty = true
  568.                     p1d=true
  569.                 end
  570.                 if dir==1 then
  571.                     panel1.off = math.min(math.max(#panel1.tab-disp,0),panel1.off+1)
  572.                     dirty = true
  573.                     p1d=true
  574.                 end
  575.             end
  576.             if x<w and x>mid+1 and y>2 and y<h-2 then
  577.                 if dir==-1 then
  578.                     panel2.off = math.max(0,panel2.off-1)
  579.                     dirty = true
  580.                     p2d=true
  581.                 end
  582.                 if dir==1 then
  583.                     panel2.off = math.min(math.max(#panel2.tab-disp,0),panel2.off+1)
  584.                     dirty = true
  585.                     p2d=true
  586.                 end
  587.             end
  588.         end
  589.     end
  590.     if p2d then
  591.         for i=1,#panel2.tab do
  592.             local p = panel2.tab[i]
  593.             p.problems = {}
  594.             if p.conflict then
  595.                 for j=1,#p.conflict do
  596.                     for k=1,#panel2.tab do
  597.                         if p.conflict[j]==panel2.tab[k].name then
  598.                             table.insert(p.problems,"Conflict: "..p.conflict[j])
  599.                         end
  600.                     end
  601.                 end
  602.             end
  603.             if p.require then
  604.                 p.warnings = {}
  605.                 for j=1,#p.require do
  606.                     local need=true
  607.                     for k=1,#panel2.tab do
  608.                         if p.require[j]==panel2.tab[k].name then
  609.                             need=false
  610.                         end
  611.                     end
  612.                     if need then
  613.                         table.insert(p.warnings,"Requires: "..p.require[j])
  614.                     end
  615.                 end
  616.             end
  617.         end
  618.     end
  619. end
  620.  
  621. term.setBackgroundColor(colors.black)
  622. term.setTextColor(colors.white)
  623. term.clear()
  624. term.setCursorPos(1, 1)
  625.  
  626. ---
  627. end
  628. ---
  629.  
  630. local addrequired
  631. addrequired = function(m)
  632.     local req = m.require or m.required or {}
  633.     for i=1,#req do
  634.         for k=1,#contents.modules do
  635.             local m2 = contents.modules[k]
  636.             if m2==req[i] then
  637.                 table.insert(panel2.tab,{name=m2.name})
  638.                 addrequired(m2)
  639.             end
  640.         end
  641.     end
  642. end
  643.  
  644. for k,v in pairs(prevmods or {}) do
  645.     fs.delete(v.file)
  646. end
  647.  
  648. local newm = {}
  649. for i=1,#contents.modules do
  650.     local m = contents.modules[i]
  651.     if hasn(panel2.tab, m.name) then
  652.         print("Downloading \""..m.name.."\"")
  653.         local f = m.file
  654.         table.insert(newm,m)
  655.         for j=1,#f do
  656.             if f:sub(j,j)=="/" then
  657.                 local found = f:sub(1,j-1)
  658.                 if not fs.exists(found) then
  659.                     fs.makeDir(found)
  660.                 end
  661.             end
  662.         end
  663.         local file = fs.open(f,"w")
  664.         local content = http.get(baseurl..f).readAll()
  665.         file.write(content)
  666.         file.close()
  667.     end
  668. end
  669.  
  670.     local f = fs.open(".installed_modules","w")
  671.     f.write(textutils.serialize(newm))
  672.     f.close()
  673.  
  674. term.setTextColor(colors.red)
  675. print("Done installing ToxIcOS "..(contents.version or "ALPHA"))
  676. term.setTextColor(colors.white)
Advertisement
Add Comment
Please, Sign In to add comment