Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --]] Game of life PRO installer by Lewisk3 [[--
- scp = term.setCursorPos
- stc = term.setTextColor
- sbc = term.setBackgroundColor
- local w,h = term.getSize()
- local dxoff = 0
- local dyoff = 0
- local function drawTopBar()
- scp(6,1)
- sbc(colors.gray)
- term.clearLine()
- write("(c)Lewisk's Game of life Pro, Installer.")
- end
- local function fade(d,speed)
- local fadecolors = {'black','gray','lightGray','white'}
- if(d == true)then
- -- fade in
- for i = 1, #fadecolors do
- sbc(colors[fadecolors[i]])
- term.clear()
- sleep(speed)
- end
- else
- -- fade out
- for i = #fadecolors, 1, -1 do
- sbc(colors[fadecolors[i]])
- term.clear()
- sleep(speed)
- end
- end
- end
- fade(true,0.1)
- fade(false,0.2)
- local function drawMenu(offin,bcolor,txt)
- if(offin)then
- paintutils.drawFilledBox(dxoff,2,dxoff+30,19,colors.black)
- dxoff = -10
- for i = 0, 10 do
- term.current().setVisible(true)
- paintutils.drawFilledBox(dxoff,2,dxoff+30,19,colors.lightGray)
- paintutils.drawFilledBox(dxoff,2,dxoff+30,4,bcolor)
- term.current().setVisible(false)
- sleep(0.1)
- paintutils.drawFilledBox(dxoff,2,dxoff+30,19,colors.black)
- dxoff = dxoff + 1
- end
- term.current().setVisible(true)
- paintutils.drawFilledBox(dxoff,2,dxoff+30,19,colors.lightGray)
- paintutils.drawFilledBox(1,2,dxoff+30,4,bcolor)
- sbc(bcolor)
- scp( ( (dxoff+30)/2 ) - #txt/2 ,3)
- write(txt)
- sbc(colors.lightGray)
- else
- paintutils.drawFilledBox(dxoff,2,dxoff+30,19,colors.black)
- dxoff = 10
- for i = 0, 10 do
- term.current().setVisible(true)
- paintutils.drawFilledBox(1,2,dxoff+dxoff*3,19,colors.lightGray)
- paintutils.drawFilledBox(1,2,dxoff+dxoff*3,4,bcolor)
- term.current().setVisible(false)
- sleep(0.1)
- paintutils.drawFilledBox(1,2,dxoff+dxoff*3,19,colors.black)
- dxoff = dxoff - 1
- end
- term.current().setVisible(true)
- paintutils.drawFilledBox(dxoff,2,dxoff+dxoff*3,19,colors.black)
- end
- end
- local function openMenu(moptions,dx,dy,startselected)
- local sop = startselected
- local active = true
- local function draw()
- for i = 1, #moptions do
- scp(dx,dy+(i-1))
- if(sop == i)then
- write('[ ' .. moptions[i] .. ' ]')
- else
- write(' ' .. moptions[i] .. ' ')
- end
- end
- end
- local function update()
- draw()
- while active do
- ev = {os.pullEvent()}
- if(ev[1] == 'key')then
- if(ev[2] == keys.up and sop > 1)then sop = sop - 1 end
- if(ev[2] == keys.down and sop < #moptions)then sop = sop + 1 end
- draw()
- if(ev[2] == keys.enter)then active = false return sop end
- end
- end
- end
- return update()
- end
- local function start()
- drawTopBar()
- drawMenu(true,colors.green,"Install Options.")
- sbc(colors.lightGray)
- scp(1,5)
- write("Use arrows to select.")
- scp(1,6)
- write("Press enter to confirm.")
- local result = openMenu({'Install Full',"Install Grid",'Exit Install'},4,8,1)
- if(result == 3)then sbc(colors.black) stc(colors.white) scp(1,1) term.clear() return false end
- if(result == 1)then
- drawMenu(false,colors.green)
- drawMenu(true,colors.blue,"Install To?")
- scp(5,5)
- write("Location: ")
- scp(5,6)
- sbc(colors.gray)
- write(string.rep(" ",15))
- scp(5,6)
- local loc = read()
- scp(5,9)
- sbc(colors.lightGray)
- write("Install to: " .. loc .. " ?")
- result = openMenu({'Yeah','Nope'},10,10,1)
- if(result == 1)then
- if(not http)then
- scp(1,11)
- write("HTTP is disabled!, please enable.")
- scp(1,12)
- write("Press any key.")
- os.pullEvent("key")
- drawMenu(false,colors.blue)
- start()
- else
- scp(1,11)
- write("Fetching file(s)..")
- local gridcont = http.get("http://pastebin.com/raw/QEXpahe1")
- local gamecont = http.get("http://pastebin.com/raw/R3HfhA4x")
- if(gridcont == nil or gamecont == nil)then
- scp(1,11)
- write("Failed to download file.")
- scp(1,12)
- write("Press any key.")
- os.pullEvent("key")
- drawMenu(false,colors.blue)
- start()
- else
- gridcont=gridcont.readAll()
- gamecont=gamecont.readAll()
- if(not fs.isDir(shell.resolve(loc)))then
- fs.makeDir(shell.resolve(loc))
- end
- f = fs.open(shell.resolve(loc) .. "/grid", "w")
- f.write(gridcont)
- f.close()
- scp(1,12)
- write("Grid installed to: " .. shell.resolve(loc))
- f = fs.open(shell.resolve(loc) .. "/gameoflife", "w")
- f.write(gamecont)
- f.close()
- scp(1,13)
- write("Game installed to: " .. shell.resolve(loc))
- scp(1,14)
- write("Press any key.")
- os.pullEvent("key")
- drawMenu(false,colors.blue)
- start()
- end
- end
- elseif(result == 2)then
- drawMenu(false,colors.blue)
- start()
- end
- elseif(result == 2)then
- drawMenu(false,colors.green)
- drawMenu(true,colors.blue,"Install Grid To?")
- scp(5,5)
- write("Location: ")
- scp(5,6)
- sbc(colors.gray)
- write(string.rep(" ",15))
- scp(5,6)
- local loc = read()
- scp(5,9)
- sbc(colors.lightGray)
- write("Install Grid to: " .. loc .. " ?")
- result = openMenu({'Yeah','Nope'},10,10,1)
- if(result == 1)then
- if(not http)then
- scp(1,11)
- write("HTTP is disabled!, please enable.")
- scp(1,12)
- write("Press any key.")
- os.pullEvent("key")
- drawMenu(false,colors.blue)
- start()
- else
- scp(1,11)
- write("Fetching file..")
- local cont = http.get("http://pastebin.com/raw/QEXpahe1")
- if(cont == nil)then
- scp(1,11)
- write("Failed to download file.")
- scp(1,12)
- write("Press any key.")
- os.pullEvent("key")
- drawMenu(false,colors.blue)
- start()
- else
- cont=cont.readAll()
- if(not fs.isDir(shell.resolve(loc)))then
- fs.makeDir(shell.resolve(loc))
- end
- f = fs.open(shell.resolve(loc) .. "/grid", "w")
- f.write(cont)
- f.close()
- write("Grid install to: " .. shell.resolve(loc))
- scp(1,12)
- write("Press any key.")
- os.pullEvent("key")
- drawMenu(false,colors.blue)
- start()
- end
- end
- elseif(result == 2)then
- drawMenu(false,colors.blue)
- start()
- end
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement