KevY007

SetShieldInstaller

Dec 19th, 2015
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.27 KB | None | 0 0
  1. local installAs = "setshield.app"
  2. local function Setup()
  3.   term.setCursorPos(10,12)
  4.   print("                                                    ")
  5.  
  6.     term.setCursorPos(20,14)
  7.     print("             ")
  8.         term.setCursorPos(20,15)
  9.         print("             ")
  10. sleep(0.1)
  11. term.setCursorPos(10,12)
  12. print("Read files...")
  13.  
  14. term.setCursorPos(5,10)
  15. textutils.slowPrint("IIIIIIIIIIIIIIII")
  16.  
  17.  
  18.  
  19.  
  20. if fs.exists("disk/Setup/install_pc_1") then
  21.   if fs.exists("disk/Setup/install_pc_2") then
  22.     local hwnd = fs.open("disk/Setup/install_pc_2", "r")
  23.     installAs = hwnd.readAll("disk/Setup/install_pc_2")
  24.     hwnd.close(hwnd)
  25.   end
  26.   sleep(0.1)
  27.   term.setCursorPos(10,12)
  28.   print("                                                    ")
  29.   sleep(0.1)
  30.   term.setCursorPos(10,12)
  31.   print("Installing " ..installAs.. "...")
  32.  
  33.   term.setCursorPos(5,10)
  34. textutils.slowPrint("IIIIIIIIIIIIIIIIIIIIIIIIIIIII")
  35.  
  36.  
  37.  
  38.  
  39. term.setCursorPos(5,10)
  40. textutils.slowPrint("IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII")
  41.  
  42.   term.setCursorPos(10,12)
  43.   print("                                ")
  44.   if fs.exists(installAs) then
  45.   fs.delete(installAs)
  46.   end
  47.  
  48. fs.copy("disk/Setup/install_pc_1", installAs)
  49.  
  50.   term.setCursorPos(10,12)
  51.   print("Installed, Rebooting to apply changes")
  52.   print("Installed file is named as " ..installAs.. "")
  53.   sleep(3)
  54.   shell.run("eject left")
  55. shell.run("eject top")
  56. shell.run("eject bottom")
  57. shell.run("eject back")
  58. shell.run("eject right")
  59. shell.run("eject front")
  60.   os.reboot()
  61.  
  62.  
  63. else
  64.  
  65.   term.setCursorPos(10,12)
  66.   print("                                  ")
  67.   sleep(0.1)
  68.   term.setCursorPos(10,12)
  69.   print("Error Code 0x91 occured! (Corrupt Installer)")
  70.   sleep(2)
  71.   os.reboot()
  72. end
  73.  
  74.  
  75.  
  76. end
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. local function Aus()
  96. os.pullEvent = os.pullEventRaw
  97. opcje = {}
  98. wybor = 1
  99.  
  100. opcje[1] = "Install"
  101. opcje[2] = "Cancel"
  102.  
  103. function uruchom(numer)
  104. if numer == 1 then
  105. Setup()
  106. end
  107.  
  108.  if numer == 2 then
  109. shell.run("eject left")
  110. shell.run("eject top")
  111. shell.run("eject bottom")
  112. shell.run("eject back")
  113. shell.run("eject right")
  114. shell.run("eject front")
  115. term.clear()
  116. os.reboot()
  117. end
  118.  
  119.  
  120.  
  121. end
  122.  
  123.  
  124. function Taste()
  125.  sleep(0)
  126.  event, argument = os.pullEvent()
  127.  if event == "key" then
  128.   if argument == 28 then
  129.    return uruchom(wybor)
  130.   elseif argument == 200 then
  131.    if wybor == 1 then
  132.    else
  133.     wybor = wybor - 1
  134.    end
  135.   elseif argument == 208 then
  136.    if wybor == table.getn(opcje) then
  137.    else
  138.     wybor = wybor + 1
  139.    end
  140.   else
  141.    return Taste()
  142.   end
  143.  else
  144.   return Taste()
  145.  end
  146.  return menu()
  147. end
  148.  
  149. function menu()
  150. term.clear()
  151. term.setCursorPos(1,3)
  152. print("|   ### ###   |")
  153. print("|   #   #     |")
  154. print("|   ### ###   |")
  155. print("|     #   #   |")
  156. print("|   ### ###   |")
  157.  
  158. term.setCursorPos(8,1)
  159. print("Welcome to the SetShield Wizard.")
  160. term.setCursorPos(4,10)
  161. print("[-------------------------------------------]")
  162. term.setCursorPos(10,12)
  163. print("Are you sure you want to install this program?")
  164. print("")
  165.  
  166.  for i=1, table.getn(opcje) do
  167.   if wybor == i then
  168.    print("                      [ "..opcje[i].." ]")
  169.   else
  170.    print("                        "..opcje[i].."  ")
  171.   end
  172.  end
  173.  
  174. return Taste()
  175. end
  176. return menu()
  177. end
  178. Aus()
Add Comment
Please, Sign In to add comment