Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,h = term.getSize()
- local rw = w/2
- local rh = h/2
- local scp = term.setCursorPos
- local sbc = term.setBackgroundColor
- local stc = term.setTextColor
- function defwindow()
- return colors.white,colors.blue,colors.black,colors.lightGray --term.getBackgroundColor()
- end
- function window_write(ww,wh,txt)
- local x, y = term.getCursorPos()
- scp(((rw+1) - ww/2)+x,((rh+2) - wh/2)+y)
- write(txt)
- end
- function window(dowait,title,text,ww,wh,bgcolor,topcolor,sdwcolor,ccol)
- if(dowait == nil)then dowait = true end
- paintutils.drawFilledBox(
- (rw+1) - ww/2,
- (rh+2) - wh/2,
- (rw+1) + ww/2,
- (rh+2) + wh/2,
- sdwcolor
- )
- paintutils.drawFilledBox(
- rw - ww/2,
- (rh+1) - wh/2,
- rw + ww/2,
- (rh+1) + wh/2,
- bgcolor
- )
- paintutils.drawLine(
- rw - ww/2,
- (rh+1) - wh/2,
- rw + ww/2,
- (rh+1) - wh/2,
- topcolor
- )
- sbc(topcolor)
- stc(2^ ( 15 - (math.log(sdwcolor) / math.log(2) ) ))
- scp((rw-ww/2),(rh+1) - wh/2)
- write(title)
- sbc(bgcolor)
- stc(sdwcolor)
- local strlin = ( ( rh + 2 ) - wh/2) +1
- scp((rw-ww/2), strlin)
- local xx = 0
- local online = 1
- local ind = 0
- for i = 1, #text do
- xx = xx + 1
- if(text:sub(ind,ind+1) == "/n")then
- online = online + 1
- xx = 1
- ind = ind + 1
- else
- scp((rw-ww/2)+xx,strlin+online)
- write(text:sub(ind,ind))
- end
- ind = ind + 1
- end
- if(dowait)then
- os.pullEvent("key")
- paintutils.drawFilledBox(
- (rw) - ww/2,
- (rh) - wh/2,
- (rw+1) + ww/2,
- (rh+2) + wh/2,
- ccol
- )
- end
- end
- function askyn()
- local inyn = true
- local isy = false
- while(inyn)do
- local e, k = os.pullEvent("key")
- if(k == keys.y)then
- isy = true
- inyn = false
- break
- elseif(k == keys.n)then
- inyn = false
- break
- end
- end
- return isy
- end
- paintutils.drawFilledBox(1,1,w,h,colors.lightGray)
- window(1,"StoneLock Installer"," Welcome to StoneLock. /n/n A lock designed for all /n StoneFruit staff members.",28,8,defwindow())
- window(false,"StoneLock Installer"," Install StoneLock? ",28,8,defwindow())
- sbc(colors.gray)
- scp(4,8)
- window_write(38,10,string.rep(" ",29))
- scp(16,8)
- stc(colors.white)
- window_write(38,10,"Y/n?")
- if(askyn())then
- paintutils.drawFilledBox(1,1,w,h,colors.lightGray)
- window(false,"StoneLock Installer","Download to:",38,8,defwindow())
- scp(1,4)
- sbc(colors.gray)
- window_write(38,8,string.rep(" ",35))
- scp(rw - 17, 11)
- stc(colors.white)
- local to = read()
- local file = http.get("http://pastebin.com/raw.php?i=Mgs8dTx2")
- if file then
- local f = fs.open(to,"w")
- f.write(file.readAll())
- f.close()
- window(1,"StoneLock Installer","Downloaded file: " .. to .. ". /n Successfully.",38,8,defwindow())
- paintutils.drawFilledBox(1,1,w,h,colors.lightGray)
- window(1,"StoneLock Installer","Setup completed! /n Press any key.",38,8,defwindow())
- sbc(colors.black)
- stc(colors.white)
- scp(1,1)
- term.clear()
- else
- window(false,"StoneLock Installer","/n/n download failed.",38,8,defwindow())
- stc(colors.red)
- scp(1,1)
- window_write(38,8,"FATAL ERROR")
- os.pullEvent("key")
- window(1,"Fatal Error","download failed /n press any key to exit.",38,8,defwindow())
- sbc(colors.black)
- stc(colors.white)
- scp(1,1)
- term.clear()
- end
- else
- sbc(colors.black)
- stc(colors.white)
- scp(1,1)
- term.clear()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement