5bitesofcookies

LimitlessBox installer V2

Jul 1st, 2014
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. --are theyrunning in a tabbed os?
  6. --[[
  7. This is Install Utils by Geforce Fan. It's found @ BvL9rr0N , please get it from there to be sure it's up to date.
  8. Just paste it into your installer!
  9. ]]
  10. function pasteRun(id,aa)
  11.   if not type(id)=="string" then
  12.     return "Must has string!"
  13.   end
  14.   --get program off pastebin
  15.   local a=http.get("http://www.pastebin.com/raw.php?i="..id)
  16.   if not a then return false end
  17.   a=a.readAll()
  18.   if not a then return false end
  19.   local env = {}
  20.   a=loadstring(a)
  21.   if not a then return false end
  22.   local env= setmetatable({},{__index=_G})
  23.   setfenv(a,env)
  24.    
  25.   local ok,err=pcall(a,unpack(aa))
  26.   --a()
  27.   if (not ok) and err then
  28.     printError("Error running "..id..": "..err)
  29.     return false
  30.   end
  31.   return err,env
  32. end
  33. function pastePI(id,tab)
  34.   local returned,env = pasteRun(id)
  35.   _G[tab] = env
  36. end
  37. function pasteGet(id)
  38.   if not type(id)=="string" then
  39.     return "Must has string!"
  40.   end
  41.   --get program off pastebin
  42.   local a=http.get("http://www.pastebin.com/raw.php?i="..id)
  43.   if not a then return false end
  44.   a=a.readAll()
  45.   if not a then return false end
  46.   return a
  47. end
  48. function pasteGetAndSave(url,loc)
  49.   local a=pasteGet(url)
  50.   --write it
  51.   local b = fs.open(loc,"w")
  52.   if b then
  53.     b.write(a)
  54.     b.close()
  55.     return true
  56.   end
  57.   return false
  58. end
  59. --This is the end of installutils. The rest is this person's installer.
  60.  
  61.  
  62.  
  63. local _,ty=term.getSize()
  64. local tabbed = true
  65. if ty == 18 then
  66.   tabbed=true
  67. end
  68. pGetNDL= pasteGetAndSave
  69. local function cPrint(y,text)
  70.   --centerprinttext
  71.   local h=term.getSize()
  72.   h=(h-#text)/2
  73.   term.setCursorPos(h,y)
  74.   write(text)
  75. end
  76. local function drawInsUI()
  77.   term.setBackgroundColor(colors.gray)
  78.   term.clear()
  79.   term.setBackgroundColor(colors.orange)
  80.   term.setTextColor(colors.black)
  81.   term.setCursorPos(1,1)
  82.   print("                                                   ")
  83.   cPrint(1,"LimitlessBox V2")
  84.   term.setBackgroundColor(colors.gray)
  85.   term.setTextColor(colors.orange)
  86.   --make a box where the info will be displayed
  87.   paintutils.drawLine(2,3,2,18,colors.lightGray)
  88.   paintutils.drawLine(50,3,50,18,colors.lightGray)
  89.   paintutils.drawLine(50,18,2,18,colors.lightGray)
  90.   paintutils.drawLine(50,3,2,3,colors.lightGray)
  91.   --draw next and previos buttons
  92.   term.setBackgroundColor(colors.orange)
  93.   term.setTextColor(colors.black)
  94.   term.setCursorPos(50,ty)
  95.   write">"
  96.   term.setCursorPos(2,ty)
  97.   write"<"
  98.   term.setBackgroundColor(colors.green)
  99.   term.setTextColor(colors.black)
  100.   cPrint(ty,"DOWNLOAD!")
  101.   term.setBackgroundColor(colors.gray)
  102.   term.setTextColor(colors.orange)
  103. end
  104. local function appPrint(t)
  105.   local _,y=term.getCursorPos()
  106.   term.setCursorPos(3,y)
  107.   print(t)
  108. end
  109. local function handleSapphari()
  110.   cPrint(4,"Sapphari:")
  111.   print()
  112.   print()
  113.   appPrint("      Sapphari is a web browser for CC.   ")
  114.   appPrint("      Sapphari has everything you'd expect-- ")
  115.   appPrint("      Tabs, bookmarks, site switching, etc. ")
  116.   appPrint("      Welcome to the internet!     ")
  117.   cPrint(11,"Current version: 1.0")
  118.  
  119. end
  120. local function handlePokeCCLevelEditor()
  121.  
  122.   cPrint(4,"PokeCC Level Editor:")
  123.   cPrint(5,"Not out yet.")
  124.  
  125. end
  126. local function handlePokeCC()
  127.   cPrint(4,"Note to users:")
  128.   cPrint(5,"(this is temporry and will be removed when this space fills)just wanted everyone to know, that as of 1/11/2015 I'm working on Game-engine and will be releasing it soon-ish.")
  129.  
  130.  
  131.  
  132.  
  133. end
  134. local function handleGameengine()
  135.     cPrint(4,"Game-Engine")
  136.     cPrint(5,"Sample text, lens-flare!")
  137.     cPrint(6,"See the post in general for info.")
  138. end
  139. local function handleOs()
  140.     cPrint(4,"[os]")
  141.     cPrint(5,"Sample text, lens-flare!")
  142.     cPrint(6,"No info on this, in a nobody-will-find-this-beta!")
  143. end
  144. local function handleInstaller()
  145.   --//first draw the UI
  146.   --now pass it off to the current app to install handler
  147.   if args[2] == "update" then--an app is calling this to update
  148.     os.queueEvent("mouse_click",1,23,19)--fake click dl button
  149.   end
  150.     return handleWhichApp()
  151.  
  152. end
  153. args = {...}
  154. function handleWhichApp()
  155.   while true do--don't feel like reindenting
  156.   drawInsUI()
  157.   --local currentApp={}
  158.   if not args[1] then
  159.     args[1]=1
  160.   else
  161.     args[1]=tonumber(args[1])
  162.   end
  163.   if args[1] == 1 then
  164.     handleSapphari()
  165.   elseif args[1] == 2 then
  166.     --currentApp[2] ="handlePokeCCLevelEditor"
  167.     handlePokeCC()
  168.   elseif args[1]==3 then
  169.     --currentApp[3]="handlePokeCC"
  170.     handlePokeCCLevelEditor()
  171.   elseif args[1]==4 then
  172.     handleGameengine()
  173.   elseif args[1]==5 then
  174.     handleOs()
  175.  
  176.   end
  177.   local evt,type,x,y=os.pullEvent()
  178.   if evt=='mouse_click'then
  179.     if y==ty then  
  180.       if x==2 then
  181.         if args[1]>1 then
  182.           args[1]=args[1]-1
  183.         end
  184.       elseif x==50 then
  185.         if args[1]<3 then
  186.           args[1]=args[1]+1
  187.         end
  188.       elseif x>20 and x<30 then
  189.         term.setBackgroundColor(colors.green)
  190.         term.setTextColor(colors.black)
  191.         cPrint(19,"DLing... ")
  192.         --dlbutton
  193.         if args[1]==1 then
  194.         --sapph dl
  195.           if not fs.exists("sapphInt") then
  196.             fs.makeDir("sapphInt")
  197.           end
  198.           fs.delete"sapphInt/startup"
  199.           fs.delete"sapphInt/sapphUtils"
  200.           fs.delete"sapphInt/redirect"
  201.           pGetNDL('fJ409KH1','sapphInt/startup')
  202.           pGetNDL("fU9Kj9zr","sapphInt/redirect")
  203.           pGetNDL("hyNPyhQZ","sapphInt/sapphUtils")
  204.           local ff=fs.open("sapphInt/sapphBookmarks","w")
  205.       local bo = {}
  206.       bo[1] = "Add Bookmark"
  207.       ff.writeLine(textutils.serialize(bo))
  208.       ff.close()
  209.       --make a shortcut to sapphari
  210.           ff=fs.open("Sapphari","w")
  211.       ff.writeLine('shell.run("sapphInt/startup")')
  212.       ff.close()
  213.           cPrint(ty,"DOWNLOAD!")
  214.       local i=quitw()
  215.           if i then
  216.             term.setBackgroundColor(colors.black)
  217.             term.setTextColor(colors.yellow)
  218.             term.clear()
  219.             term.setCursorPos(1,1)
  220.             print(os.version())
  221.             return i
  222.           end
  223.         elseif args[1]==2 then
  224.           --pokecc dl
  225.          
  226.         elseif args[1]==3 then
  227.         --levels dl
  228.          
  229.     elseif args[1]==4 then
  230.  
  231.  
  232.         end
  233.       end
  234.     end
  235.   end
  236. end
  237. end--for the while loop.
  238.  
  239. function quitw()
  240.   --check if updating via app
  241.   if args[2]=="update" then
  242.     term.setBackgroundColor(colors.black)
  243.     term.clear()
  244.     term.setCursorPos(1,1)
  245.     return "update"--this tells the app it was sucsessful
  246.   end
  247.   --draw a prompt
  248.   --we want this centered, so we'll use a trick'
  249.   term.setBackgroundColor(colors.lightGray)
  250.   term.setTextColor(colors.black)
  251.   cPrint(9,"   Quit?   ")
  252.   term.setBackgroundColor(colors.orange)
  253.   cPrint(10,"Do you want")
  254.   cPrint(11,"to quit?   ")
  255.   --give the user the option
  256.   term.setBackgroundColor(colors.orange)
  257.   cPrint(12,"  Yes  No  ")
  258.   --fix the mess-up
  259.   term.setBackgroundColor(colors.orange)
  260.   term.setCursorPos(20,12)
  261.   write"  "
  262.   --we must do it manual now
  263.   term.setCursorPos(25,12)
  264.   write"  "
  265.   term.setCursorPos(29,12)
  266.   print"  "
  267.  
  268.   --check for button press
  269.   while true do
  270.     local _,_,x,y=os.pullEvent()
  271.     if y==12 then
  272.       if x>21 and x<26 then
  273.         return true
  274.       elseif x>27 and x<30 then
  275.         return false
  276.       end
  277.     end
  278.   end
  279. end
  280. --if they're on a smaller screen we can't show them our fancy UI.
  281. local x,y=term.getSize()
  282. if x == 51 then else
  283.   args[2]="update"
  284. end
  285. if y==19 then else--or y==18 then else--for OSes with a menubar, fine. not sure how they'll dl, will get to that later probs
  286.   args[2]="update"
  287. end
  288. return handleInstaller()
Advertisement
Add Comment
Please, Sign In to add comment