Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Vars
- local install = {
- {id="DacLauncher",dl="d3WS3gJw",type="pb",desc="A local file browser built for CC. Can also access files stored online through a proprietary format."},
- {id="DacStorage",dl="Ct3qAdnM",type="pb",desc="A cloud-based file backup solution using the DacPages login server. The online counterpart can be found at https://dacpages.tk/files."}
- }
- local w,h = term.getSize()
- local scroll = 0
- --Functions
- local center = function(txt,width,auto,cy)
- if not width then
- width = w
- end
- if auto then
- if not cy then
- _,cy = term.getCursorPos()
- end
- term.setCursorPos((width-#txt)/2+1,cy)
- term.write(txt)
- else
- return (width-#txt)/2+1
- end
- end
- local drawBars = function()
- paintutils.drawLine(1,1,w,1,colors.red)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.setCursorPos(2,1)
- term.write("DacInstaller")
- paintutils.drawLine(1,h,w,h,colors.lime)
- term.setBackgroundColor(colors.lime)
- center("Install Selected",w,true,h)
- end
- local drawOptions = function()
- for i = 1,h-2 do
- if true then
- if i == 1 and scroll > 0 then
- term.setBackgroundColor(colors.gray)
- paintutils.drawLine(1,2,w,2,colors.gray)
- center("^",w,true,2)
- elseif i == h-2 and #install-(h-2)-scroll > 0 then
- term.setBackgroundColor(colors.gray)
- paintutils.drawLine(1,h-1,w,h-1,colors.gray)
- center("^",w,true,h-1)
- elseif install[i] then
- local c
- if install[i].select then
- c = colors.gray
- term.setBackgroundColor(colors.gray)
- else
- c = colors.black
- term.setBackgroundColor(colors.black)
- end
- paintutils.drawLine(1,i+1,w,i+1,c)
- term.setCursorPos(2,i+1)
- term.write(install[i].id)
- term.setCursorPos(w-2,i+1)
- term.write("[i]")
- else
- paintutils.drawLine(1,i+1,w,i+1,colors.black)
- end
- end
- end
- end
- local info = function(title,info)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setBackgroundColor(colors.red)
- paintutils.drawLine(1,1,w,1,colors.red)
- center(title,w,true,1)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,2)
- print(info)
- term.setBackgroundColor(colors.red)
- paintutils.drawLine(1,h,w,h,colors.red)
- center("Close",w,true,h)
- while true do
- local e,a,b,c = os.pullEvent("mouse_click")
- if c == h then
- drawBars()
- drawOptions()
- break
- end
- end
- end
- --Code
- drawBars()
- drawOptions()
- while true do
- local e,a,b,c = os.pullEvent()
- if e == "mouse_click" then
- if c == 2 and scroll > 0 then
- scroll = scroll - 1
- drawOptions()
- elseif c == h-1 and #install-(h-2)-scroll > 0 then
- scroll = scroll + 1
- drawOptions()
- elseif c > 1 and c < h then
- if (b > w-3) then
- info(install[c-1+scroll].id,install[c-1+scroll].desc)
- else
- install[c-1+scroll].select = not install[c-1+scroll].select
- drawOptions()
- end
- elseif c == h then
- break
- end
- end
- end
- term.setBackgroundColor(colors.black)
- term.clear()
- local count = 0
- for i = 1,#install do
- if install[i].select then
- count = count + 1
- end
- end
- local total = count
- for i = 1,#install do
- if install[i].select then
- term.clear()
- term.setCursorPos(1,1)
- term.write("Installing... ("..count.." / "..total..")")
- if install[i].type == "pb" then
- term.setCursorPos(1,2)
- shell.run("pastebin","get",install[i].dl,install[i].id)
- end
- end
- end
Add Comment
Please, Sign In to add comment