pepeknamornik

Instalační program

Apr 18th, 2015 (edited)
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.12 KB | None | 0 0
  1. local w, h = term.getSize()
  2.  
  3. if verzelist == nil then
  4.     shell.run ("pastebin get a50Y0TaF /verze")
  5.     verzelist = 1
  6.     end
  7.    
  8.     local data = fs.open ("/verze", "r")
  9.         local os1 = data.readLine()
  10.         local os2 = data.readLine()
  11.         local os3 = data.readLine()
  12.         local os4 = data.readLine()
  13.         local os5 = data.readLine()
  14.         local os6 = data.readLine()
  15.         local cos1 = data.readLine()
  16.         local cos2 = data.readLine()
  17.         local cos3 = data.readLine()
  18.         local cos4 = data.readLine()
  19.         local cos5 = data.readLine()
  20.         local cos6 = data.readLine()
  21.         data.close ()
  22.        
  23. local function bgc(barvaP) term.setBackgroundColor(barvaP) end
  24. local function txc(barvaP) term.setTextColor(barvaP) end
  25. local function curs(xi,yi) term.setCursorPos(xi,yi) end
  26.        
  27. local function prc(text, y)
  28.   local w = term.getSize()
  29.   local _, cy = term.getCursorPos()
  30.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  31.   write(text)
  32. end
  33.  
  34. function instalace ()
  35.        
  36.     if oss == nil then
  37.         oss = 1
  38.         end
  39.          
  40.     term.setBackgroundColor(colors.white)
  41.     term.setTextColor(colors.blue)
  42.     term.clear ()
  43.     prc ("Installation of Pepdroll OS",2)
  44.     term.setTextColor(colors.black)
  45.     prc ("+------------------------------------------+",8)
  46.     prc ("|                                          |",9)
  47.     prc ("|                                          |",10)
  48.     prc ("|                                          |",11)
  49.     prc ("|                                          |",12)
  50.     prc ("|                                          |",13)
  51.     prc ("|                                          |",14)
  52.     prc ("+------------------------------------------+",15)
  53.     term.setBackgroundColor(colors.red)
  54.         term.setTextColor(colors.white)
  55.         prc(" Install ", 17)
  56.            
  57.     local myWindow = window.create(term.current(),(w/2)-21,9,42,6)
  58.     myWindow.setBackgroundColor(colors.white)
  59.     myWindow.clear()
  60.     term.setBackgroundColor(colors.lightBlue)
  61.     term.setTextColor(colors.black)
  62.     myWindow.setCursorPos (1,oss)
  63.     write ">"
  64.     myWindow.setCursorPos (42,oss)
  65.     write "<"
  66.     if oss == 1 then bgc(colors.lightBlue) else bgc(colors.white) end
  67.     myWindow.setCursorPos (2,1)
  68.     write("                                        ")
  69.     myWindow.setCursorPos (2,1)
  70.     write (os1)
  71.     if oss == 2 then bgc(colors.lightBlue) else bgc(colors.white) end
  72.     myWindow.setCursorPos (2,2)
  73.     write("                                        ")
  74.     myWindow.setCursorPos (2,2)
  75.     write (os2)
  76.     txc(colors.lightGray)
  77.     if oss == 3 then bgc(colors.lightBlue) else bgc(colors.white) end
  78.     myWindow.setCursorPos (2,3)
  79.     write("                                        ")
  80.     myWindow.setCursorPos (2,3)
  81.     write (os3)
  82.     if oss == 4 then bgc(colors.lightBlue) else bgc(colors.white) end
  83.     myWindow.setCursorPos (2,4)
  84.     write("                                        ")
  85.     myWindow.setCursorPos (2,4)
  86.     write (os4)
  87.     if oss == 5 then bgc(colors.lightBlue) else bgc(colors.white) end
  88.     myWindow.setCursorPos (2,5)
  89.     write("                                        ")
  90.     myWindow.setCursorPos (2,5)
  91.     write (os5)
  92.     if oss == 6 then bgc(colors.lightBlue) else bgc(colors.white) end
  93.     myWindow.setCursorPos (2,6)
  94.     write("                                        ")
  95.     myWindow.setCursorPos (2,6)
  96.     write (os6)
  97.  
  98.     while true do
  99.         local event, button, x, y = os.pullEvent("mouse_click")
  100.  
  101.         if x >= (w/2)-21 and x <= (w/2)+20 and y == 9 and button == 1 then
  102.         oss = 1
  103.         instalace ()
  104.         elseif x >= (w/2)-21 and x <= (w/2)+20 and y == 10 and button == 1 then
  105.         oss = 2
  106.         instalace ()
  107.         elseif x >= (w/2)-21 and x <= (w/2)+20 and y == 11 and button == 1 then
  108.         oss = 3
  109.         instalace ()
  110.         elseif x >= (w/2)-21 and x <= (w/2)+20 and y == 12 and button == 1 then
  111.         oss = 4
  112.         instalace ()
  113.         elseif x >= (w/2)-21 and x <= (w/2)+20 and y == 13 and button == 1 then
  114.         oss = 5
  115.         instalace ()
  116.         elseif x >= (w/2)-21 and x <= (w/2)+20 and y == 14 and button == 1 then
  117.         oss = 6
  118.         instalace ()
  119.         elseif x >= (w/2)-4 and x <= (w/2)+4 and y == 17 and button == 1 then
  120.         fs.delete ("/verze")
  121.         verzelist = nil
  122.         instalaceos ()
  123.         end
  124.     end
  125. end
  126.  
  127. function instalaceos ()
  128.     term.setBackgroundColor(colors.white)
  129.     term.setTextColor(colors.blue)
  130.     term.clear ()
  131.     prc ("Starting installation, please wait",8)
  132.     if oss == 1 then
  133.         code = cos1
  134.     elseif oss == 2 then
  135.         code = cos2
  136.     elseif oss == 3 then
  137.         code = cos3
  138.     elseif oss == 4 then
  139.         code = cos4
  140.     elseif oss == 5 then
  141.         code = cos5
  142.     elseif oss == 6 then
  143.         code = cos6
  144.         end
  145.  
  146. if code == "" then
  147.     instalace ()
  148. elseif code == "" then
  149.     instalace ()
  150. elseif code == nil then
  151.     instalace ()
  152. else
  153.     term.setBackgroundColor(colors.white)
  154.         term.setTextColor(colors.white)
  155.         term.setCursorPos (1,17)
  156.         fs.delete ("/instalace")
  157.         shell.run("pastebin run", code)
  158. end
  159.     end
  160.    
  161. function start ()
  162.  
  163. if fs.exists ("/system/RAM/pep-ins") then
  164.     install ()
  165. end
  166.  
  167. print("Booting from media.")
  168. print ""
  169. sleep(1)
  170.     instalace ()
  171. end
  172.  
  173. start ()
Add Comment
Please, Sign In to add comment