Guest User

limitlessboxv2

a guest
Jul 1st, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.26 KB | None | 0 0
  1. --license:
  2. --you are free to modify, distribute, and re-license this code. This license does not apply to things downloaded via this code.
  3. --here's an actually decent installer
  4. --made in LuaEdit
  5. local function pGetNDL(id,file)
  6.   theFile = http.get("http://www.pastebin.com/raw.php?i="..id)
  7.   theFile=theFile.readAll()
  8.   theF=fs.open(file,"w")
  9.   theF.write(theFile)
  10.   theF.close()
  11. end
  12. local function cPrint(y,text)
  13.   --centerprinttext
  14.   local h=term.getSize()
  15.   h=(h-#text)/2
  16.   term.setCursorPos(h,y)
  17.   write(text)
  18. end
  19. local function drawInsUI()
  20.   term.setBackgroundColor(colors.gray)
  21.   term.clear()
  22.   term.setBackgroundColor(colors.orange)
  23.   term.setTextColor(colors.black)
  24.   term.setCursorPos(1,1)
  25.   print("                                                   ")
  26.   cPrint(1,"LimitlessBox V2")
  27.   term.setBackgroundColor(colors.gray)
  28.   term.setTextColor(colors.orange)
  29.   --make a box where the info will be displayed
  30.   paintutils.drawLine(2,3,2,18,colors.lightGray)
  31.   paintutils.drawLine(50,3,50,18,colors.lightGray)
  32.   paintutils.drawLine(50,18,2,18,colors.lightGray)
  33.   paintutils.drawLine(50,3,2,3,colors.lightGray)
  34.   --draw next and previos buttons
  35.   term.setBackgroundColor(colors.orange)
  36.   term.setTextColor(colors.black)
  37.   term.setCursorPos(50,19)
  38.   write">"
  39.   term.setCursorPos(2,19)
  40.   write"<"
  41.   term.setBackgroundColor(colors.green)
  42.   term.setTextColor(colors.black)
  43.   cPrint(19,"DOWNLOAD!")
  44.   term.setBackgroundColor(colors.gray)
  45.   term.setTextColor(colors.orange)
  46. end
  47. local function appPrint(t)
  48.   local _,y=term.getCursorPos()
  49.   term.setCursorPos(3,y)
  50.   print(t)
  51. end
  52. local function handleSapphari()
  53.   cPrint(4,"Sapphari:")
  54.   print()
  55.   print()
  56.   appPrint("      Sapphari is a web browser for CC.   ")
  57.   appPrint("      Sapphari has everything you'd expect-- ")
  58.   appPrint("      Tabs, bookmarks, site switching, etc. ")
  59.   appPrint("      Welcome to the internet!     ")
  60.   cPrint(11,"Current version: 1.0")
  61.  
  62. end
  63. local function handlePokeCCLevelEditor()
  64.  
  65.   cPrint(4,"PokeCC Level Editor:")
  66.   cPrint(5,"Not out yet.")
  67.  
  68. end
  69. local function handlePokeCC()
  70.   cPrint(4,"PokeCC:")
  71.   cPrint(5,"Not out yet.")
  72.  
  73.  
  74.  
  75.  
  76. end
  77. local function handleInstaller()
  78.   --//first draw the UI
  79.   --now pass it off to the current app to install handler
  80.   if args[2] == "update" then--an app is calling this to update
  81.     os.queueEvent("mouse_click",1,23,19)--fake click dl button
  82.   end
  83.     handleWhichApp()
  84.  
  85. end
  86. args = {...}
  87. function handleWhichApp()
  88.   while true do--don't feel like reindenting
  89.   drawInsUI()
  90.   --local currentApp={}
  91.   if not args[1] then
  92.     args[1]=1
  93.   else
  94.     args[1]=tonumber(args[1])
  95.   end
  96.   if args[1] == 1 then
  97.     handleSapphari()
  98.   elseif args[1] == 2 then
  99.     --currentApp[2] ="handlePokeCCLevelEditor"
  100.     handlePokeCC()
  101.   elseif args[1]==3 then
  102.     --currentApp[3]="handlePokeCC"
  103.     handlePokeCCLevelEditor()
  104.   end
  105.   local evt,type,x,y=os.pullEvent()
  106.   if evt=='mouse_click'then
  107.     if y==19 then  
  108.       if x==2 then
  109.         if args[1]>1 then
  110.           args[1]=args[1]-1
  111.         end
  112.       elseif x==50 then
  113.         if args[1]<3 then
  114.           args[1]=args[1]+1
  115.         end
  116.       elseif x>20 and x<30 then
  117.         term.setBackgroundColor(colors.green)
  118.         term.setTextColor(colors.black)
  119.         cPrint(19,"DLing... ")
  120.         --dlbutton
  121.         if args[1]==1 then
  122.         --sapph dl
  123.           if not fs.exists("sapphInt") then
  124.             fs.makeDir("sapphInt")
  125.           end
  126.           fs.delete"sapphInt/startup"
  127.           fs.delete"sapphInt/sapphUtils"
  128.           fs.delete"sapphInt/redirect"
  129.           pGetNDL('fJ409KH1','sapphInt/startup')
  130.           pGetNDL("fU9Kj9zr","sapphInt/redirect")
  131.           pGetNDL("hyNPyhQZ","sapphInt/sapphUtils")
  132.           cPrint(19,"DOWNLOAD!")
  133.           if quitw() then
  134.             term.setBackgroundColor(colors.black)
  135.             term.setTextColor(colors.yellow)
  136.             term.clear()
  137.             term.setCursorPos(1,1)
  138.             print(os.version())
  139.             break
  140.           end
  141.         elseif args[1]==2 then
  142.           --pokecc dl
  143.          
  144.         elseif args[1]==3 then
  145.         --levels dl
  146.          
  147.         end
  148.       end
  149.     end
  150.   end
  151. end
  152. end--for the while loop.
  153.  
  154. function quitw()
  155.   --check if updating via app
  156.   if args[2]=="update" then
  157.     term.setBackgroundColor(colors.black)
  158.     term.clear()
  159.     term.setCursorPos(1,1)
  160.     error("1")--this tells the app it was sucsessful
  161.   end
  162.   --draw a prompt
  163.   --we want this centered, so we'll use a trick'
  164.   term.setBackgroundColor(colors.lightGray)
  165.   term.setTextColor(colors.black)
  166.   cPrint(9,"   Quit?   ")
  167.   term.setBackgroundColor(colors.orange)
  168.   cPrint(10,"Do you want")
  169.   cPrint(11,"to quit?   ")
  170.   --give the user the option
  171.   term.setBackgroundColor(colors.orange)
  172.   cPrint(12,"  Yes  No  ")
  173.   --fix the mess-up
  174.   term.setBackgroundColor(colors.orange)
  175.   term.setCursorPos(20,12)
  176.   write"  "
  177.   --we must do it manual now
  178.   term.setCursorPos(25,12)
  179.   write"  "
  180.   term.setCursorPos(29,12)
  181.   print"  "
  182.  
  183.   --check for button press
  184.   while true do
  185.     local _,_,x,y=os.pullEvent()
  186.     if y==12 then
  187.       if x>21 and x<26 then
  188.         return true
  189.       elseif x>27 and x<30 then
  190.         return false
  191.       end
  192.     end
  193.   end
  194. end
  195.  
  196. handleInstaller()
  197.  
  198.  
  199.  
  200. args=nil
Advertisement
Add Comment
Please, Sign In to add comment