Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --license:
- --you are free to modify, distribute, and re-license this code. This license does not apply to things downloaded via this code.
- --here's an actually decent installer
- --made in LuaEdit
- local function pGetNDL(id,file)
- theFile = http.get("http://www.pastebin.com/raw.php?i="..id)
- theFile=theFile.readAll()
- theF=fs.open(file,"w")
- theF.write(theFile)
- theF.close()
- end
- local function cPrint(y,text)
- --centerprinttext
- local h=term.getSize()
- h=(h-#text)/2
- term.setCursorPos(h,y)
- write(text)
- end
- local function drawInsUI()
- term.setBackgroundColor(colors.gray)
- term.clear()
- term.setBackgroundColor(colors.orange)
- term.setTextColor(colors.black)
- term.setCursorPos(1,1)
- print(" ")
- cPrint(1,"LimitlessBox V2")
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.orange)
- --make a box where the info will be displayed
- paintutils.drawLine(2,3,2,18,colors.lightGray)
- paintutils.drawLine(50,3,50,18,colors.lightGray)
- paintutils.drawLine(50,18,2,18,colors.lightGray)
- paintutils.drawLine(50,3,2,3,colors.lightGray)
- --draw next and previos buttons
- term.setBackgroundColor(colors.orange)
- term.setTextColor(colors.black)
- term.setCursorPos(50,19)
- write">"
- term.setCursorPos(2,19)
- write"<"
- term.setBackgroundColor(colors.green)
- term.setTextColor(colors.black)
- cPrint(19,"DOWNLOAD!")
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.orange)
- end
- local function appPrint(t)
- local _,y=term.getCursorPos()
- term.setCursorPos(3,y)
- print(t)
- end
- local function handleSapphari()
- cPrint(4,"Sapphari:")
- print()
- print()
- appPrint(" Sapphari is a web browser for CC. ")
- appPrint(" Sapphari has everything you'd expect-- ")
- appPrint(" Tabs, bookmarks, site switching, etc. ")
- appPrint(" Welcome to the internet! ")
- cPrint(11,"Current version: 1.0")
- end
- local function handlePokeCCLevelEditor()
- cPrint(4,"PokeCC Level Editor:")
- cPrint(5,"Not out yet.")
- end
- local function handlePokeCC()
- cPrint(4,"PokeCC:")
- cPrint(5,"Not out yet.")
- end
- local function handleInstaller()
- --//first draw the UI
- --now pass it off to the current app to install handler
- if args[2] == "update" then--an app is calling this to update
- os.queueEvent("mouse_click",1,23,19)--fake click dl button
- end
- handleWhichApp()
- end
- args = {...}
- function handleWhichApp()
- while true do--don't feel like reindenting
- drawInsUI()
- --local currentApp={}
- if not args[1] then
- args[1]=1
- else
- args[1]=tonumber(args[1])
- end
- if args[1] == 1 then
- handleSapphari()
- elseif args[1] == 2 then
- --currentApp[2] ="handlePokeCCLevelEditor"
- handlePokeCC()
- elseif args[1]==3 then
- --currentApp[3]="handlePokeCC"
- handlePokeCCLevelEditor()
- end
- local evt,type,x,y=os.pullEvent()
- if evt=='mouse_click'then
- if y==19 then
- if x==2 then
- if args[1]>1 then
- args[1]=args[1]-1
- end
- elseif x==50 then
- if args[1]<3 then
- args[1]=args[1]+1
- end
- elseif x>20 and x<30 then
- term.setBackgroundColor(colors.green)
- term.setTextColor(colors.black)
- cPrint(19,"DLing... ")
- --dlbutton
- if args[1]==1 then
- --sapph dl
- if not fs.exists("sapphInt") then
- fs.makeDir("sapphInt")
- end
- fs.delete"sapphInt/startup"
- fs.delete"sapphInt/sapphUtils"
- fs.delete"sapphInt/redirect"
- pGetNDL('fJ409KH1','sapphInt/startup')
- pGetNDL("fU9Kj9zr","sapphInt/redirect")
- pGetNDL("hyNPyhQZ","sapphInt/sapphUtils")
- cPrint(19,"DOWNLOAD!")
- if quitw() then
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- term.clear()
- term.setCursorPos(1,1)
- print(os.version())
- break
- end
- elseif args[1]==2 then
- --pokecc dl
- elseif args[1]==3 then
- --levels dl
- end
- end
- end
- end
- end
- end--for the while loop.
- function quitw()
- --check if updating via app
- if args[2]=="update" then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- error("1")--this tells the app it was sucsessful
- end
- --draw a prompt
- --we want this centered, so we'll use a trick'
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- cPrint(9," Quit? ")
- term.setBackgroundColor(colors.orange)
- cPrint(10,"Do you want")
- cPrint(11,"to quit? ")
- --give the user the option
- term.setBackgroundColor(colors.orange)
- cPrint(12," Yes No ")
- --fix the mess-up
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(20,12)
- write" "
- --we must do it manual now
- term.setCursorPos(25,12)
- write" "
- term.setCursorPos(29,12)
- print" "
- --check for button press
- while true do
- local _,_,x,y=os.pullEvent()
- if y==12 then
- if x>21 and x<26 then
- return true
- elseif x>27 and x<30 then
- return false
- end
- end
- end
- end
- handleInstaller()
- args=nil
Advertisement
Add Comment
Please, Sign In to add comment