Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dlPath = "https://raw.githubusercontent.com/ebernerd/cobalt-2/master/"
- local args = { ... }
- local beta = false
- if args[1] == "beta" then
- dlPath = "https://raw.githubusercontent.com/ebernerd/Cobalt/beta/"
- beta = true
- end
- local dx, dy = term.getSize()
- fs.delete("cobalt")
- local function centerPrint( text, y )
- term.clear()
- term.setCursorPos( 1, 1 )
- if beta then
- write( "Cobalt Beta Version Installer" )
- end
- local t = {}
- for i in string.gmatch( text, "%S+" ) do
- t[#t+1] = i
- end
- local lines = {[1] = ""}
- local line = 1
- for i=1, #t do
- if #tostring(lines[line].." "..t[i]) > dx then
- lines[line] = lines[line] .. "\n"
- line = line + 1
- lines[line] = " " .. t[i]
- else
- lines[line] = lines[line] .. " " .. t[i]
- end
- end
- y = y or math.ceil(dy/2-#lines/2)
- for i = 1, #lines do
- term.setCursorPos( dx/2-#lines[i]/2, y+(i-1))
- print( lines[i])
- end
- end
- local function getFile( file)
- local path = "cobalt/" .. file
- centerPrint( "Downloading " .. file .. " to \"" .. path .. "\"")
- local dl = http.get( dlPath..file )
- local h = dl.readAll()
- dl.close()
- local f = fs.open( path, "w" )
- f.write( h )
- f.close()
- end
- local function clear( colour )
- term.setBackgroundColour( colour or term.getBackgroundColour() )
- term.clear()
- term.setCursorPos( 1, 1 )
- end
- local function yn()
- local l = true
- while l do
- local event, key = os.pullEvent()
- if event == "key" then
- if key == 89 then
- return true
- elseif key == 78 then
- return false
- end
- end
- end
- end
- if beta then
- term.setTextColour( colours.grey )
- clear( colours.grey )
- centerPrint( "Beta access is currently closed. Run again without the beta argument." )
- sleep( 1 )
- os.pullEvent("key_up")
- clear( colours.black )
- else
- term.setTextColour( colours.white )
- clear( colours.grey )
- centerPrint( "Downloading Cobalt v2" )
- sleep(0.5)
- sleep(0.5)
- print()
- print( "Starting Cobalt-UI download...")
- getFile( "init.lua" )
- getFile( "lib/clasp.lua" )
- getFile( "lib/surface.lua" )
- getFile( "lib/modules/graphics/init.lua" )
- getFile( "lib/modules/graphics/classes/Canvas.lua" )
- getFile( "lib/modules/graphics/classes/Drawable.lua" )
- getFile( "lib/modules/graphics/classes/Image.lua" )
- getFile( "lib/modules/keyboard/init.lua" )
- getFile( "lib/modules/mouse/init.lua" )
- centerPrint( "Download of Cobalt complete!")
- sleep(0.5)
- centerPrint( "There are no other Cobalt packages as of yet. Enjoy Cobalt!")
- sleep(2)
- centerPrint( "Press any key to exit the installer")
- os.pullEvent('key_up')
- clear( colours.black )
- end
RAW Paste Data