Advertisement
Nhorr

NhUI v0.5 [ABANDONED] (WIP BUILD) | [Installer]

Sep 15th, 2015
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- installation: pastebin run qExuNAUg
  2. -- installing: NhUI v0.5 (for Basic and Advanced PCs/Monitors) [CraftOS 1.7 compatibility confirmed]
  3. -- info: This is a UI program-set to be used in ComputerCraft, a mod for Minecraft which adds programmable computers
  4.  
  5. -- add something that mentions when another program of the same name exists
  6.  
  7. local nhver="v0.5"
  8. local nhuiProgs={["startup"]="CjD8TqJb",["desktop"]="JUhsDLDd",[".nhuicfg"]="mbD7EU2J"}
  9. local nhuiProgList={"startup","desktop","updater","login",".nhuicfg"}
  10. local function anyKey()
  11.   sleep(.2)
  12.   local event,b,x,y=os.pullEventRaw()
  13.   if (event=="key" and b~=0) or (event=="mouse_click" and x>0 and y>0) then anyKey=nil end
  14. end
  15.  
  16. term.clear() term.setCursorPos(1,1)
  17. print("You have initiated the NhUI ("..nhver..") installer. Installing NhUI will remove the following programs:\n")
  18. print("startup       login\ndesktop       .nhuicfg\nupdater")
  19. print("\nIf you wish to rename any programs, cancel the installation and do so before continuing.\n")
  20. local x,y=term.getCursorPos()
  21. local ans=nil
  22. repeat
  23.   term.setCursorPos(x,y) term.clearLine()
  24.   term.write("Would you like to install NhUI <y/n>? ")
  25.   local input=read()
  26.   if input=="y" then ans=true
  27.   elseif input=="n" then print("\n@NhUI installation was canceled.\n@Press any key to continue.")
  28.   anyKey() os.reboot()
  29.   else print("\nPlease enter 'y' or 'n'.") end
  30. until ans==true
  31. if ans==true then print("\nWaiting for pastebin.com...") end
  32. while ans do
  33.   http.request("http://pastebin.com/")
  34.   local event=os.pullEvent()
  35.   if event=="http_failure" then print("...could not connect.\n\n@NhUI installation was canceled.\n@Press any key to continue.")
  36.   anyKey() os.reboot()
  37.   elseif event=="http_success" then print("...connection successful.\n\nClearing paths...")
  38.     for i=1, #nhuiProgList-1 do fs.delete(nhuiProgList[i]) end
  39.     print("...paths cleared.\n\nFetching files...")
  40.     shell.run("pastebin get",nhuiProgs["startup"],"startup")
  41.     shell.run("pastebin get",nhuiProgs["desktop"],"desktop")
  42.     if not fs.exists(".nhuicfg") then shell.run("pastebin get",nhuiProgs[".nhuicfg"],".nhuicfg") end
  43.     if fs.exists("startup") and fs.exists("desktop") and fs.exists(".nhuicfg") then
  44.       print("...programs fetched.\n\n@NhUI "..nhver.." installed successfully.\n@Press any key to continue.")
  45.       anyKey() os.reboot()
  46.     else error("ERROR: Program(s) failed to download likely due to a connection issue. You may attempt to re-run the installer.") end
  47.   end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement