Advertisement
Redxone

Cozy Disk Installer Maker

Jul 4th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. local op = 1
  2. local mm = 0
  3.  
  4. function clear()
  5.     term.setBackgroundColor(colors.blue)
  6.     term.clear()
  7.     term.setCursorPos(1,1)
  8.     print("Cozy File Grabber Select An Option Below And Insert Disk!")
  9. end
  10.  
  11.  
  12. local menu = {
  13.    
  14.     --["    Cozy UI     "]
  15.     ["Cozy File"] = {x=20,y=8,offset=1,url="4tt1J2D3", name="startup"};
  16.     ["Cozy Mail"] = {x=20,y=9,offset=2,url="Tsjq5eVa",name = "startup"};
  17.     ["Cozy Chat"] = {x=20,y=10,offset=3,url="7xs20hhW",name = "startup"};
  18.     [" RedDisk "] = {x=20,y=11,offset=4,url="Snj31Zwt",name = "startup"};
  19.  
  20. }
  21.  
  22. for k, v in pairs(menu) do mm = mm + 1 end
  23.  
  24. function makeDisk()
  25.  
  26.     for k, v in pairs(menu) do
  27.    
  28.         if(op == v.offset)then
  29.  
  30.             if(disk.isPresent("bottom"))then
  31.  
  32.                  
  33.                  shell.run("pastebin","get",v.url,".tmp")
  34.                  if(v.url2)then shell.run("pastebin","get",v.url2,".tmp2") end
  35.                     fs.move(".tmp","disk/"..v.name)
  36.                     if(v.url2)then fs.move(".tmp2","disk/"..v.name2) end
  37.  
  38.                 print("Install Disk Created!")
  39.                 print("press any key to continue.")
  40.                 os.pullEvent("key")
  41.                 disk.eject("bottom")
  42.             else
  43.  
  44.                 print("Please Insert Disk In Bottom Drive")
  45.                 print("press any key to continue.")
  46.                 os.pullEvent("key")
  47.                 makeDisk()
  48.  
  49.             end
  50.         end
  51.  
  52.     end
  53. end
  54.  
  55.  
  56. function drawMenu()
  57.     for k, v in pairs(menu) do  term.setCursorPos(v.x,v.y) if(op == v.offset)then print("> "..k.." <") else print("  "..k.."  ") end end
  58. end
  59.  
  60. function updateMenu()
  61.    
  62.     m = {os.pullEvent("key")}
  63.  
  64.     if(m[2] == keys.up and op > 1)then op = op - 1 end
  65.     if(m[2] == keys.down and op < mm)then op = op + 1 end
  66.     if(m[2] == keys.enter)then makeDisk() end
  67.  
  68. end
  69.  
  70. while true do
  71.  
  72.     sleep(0.01)
  73.     clear()
  74.     drawMenu()
  75.     updateMenu()
  76.  
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement