Advertisement
pepeknamornik

failstart

Jul 27th, 2015
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. local function prc(text, y)
  2.   local w = term.getSize()
  3.   local _, cy = term.getCursorPos()
  4.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  5.   write(text)
  6. end
  7.  
  8.  
  9.    
  10. function clear()
  11.   term.clear()
  12.   term.setBackgroundColor(colors.white)
  13.   for i=1,w do
  14.     for j=1,h do
  15.       term.setCursorPos(i,j)
  16.       write(" ")
  17.     end
  18.   end
  19. end
  20.  
  21. function start ()
  22.     if not fs.exists ("/system/RAM/bluescreen") then
  23.         local data = fs.open ("/system/RAM/bluescreen", "w")
  24.         data.close ()
  25.         shell.run ("/system/desktop")
  26.     end
  27.    
  28.     term.setBackgroundColor(colors.blue)
  29.     term.setTextColor(colors.white)
  30.     term.clear()
  31.     prc ("Advanced Boot menu", 2)
  32.     prc ("Select the next step", 5)
  33.    
  34.     term.setCursorPos(5, 10)
  35.     print ("- Start normally")
  36.     term.setCursorPos(5, 12)
  37.     print ("- Commander")
  38.     term.setCursorPos(5, 14)
  39.     print ("- Shutdown")
  40.     term.setBackgroundColor(colors.purple)
  41.  
  42.     while true do
  43.     local event, button, x, y = os.pullEvent("mouse_click")
  44.     xy = x..","..y
  45.    
  46.     if x >= 5 and x <= 20 and y == 12 and button == 1 then
  47.     term.setBackgroundColor(colors.black)
  48.     term.setTextColor(colors.white)
  49.     term.clear()
  50.     term.setCursorPos(5, 12)
  51.     print ("- Commander")
  52.     sleep (0.2)
  53.     local data = fs.open ("/system/RAM/ercommander", "w")
  54.         data.close ()
  55.     term.setCursorPos(1,1)
  56.     shell.run ("/system/api/commander")
  57.     elseif x >= 5 and x <= 20 and y == 10 and button == 1 then
  58.     term.setCursorPos(5, 10)
  59.     print ("- Start normally")
  60.     sleep (0.2)
  61.     preskoklog ()
  62.     elseif x >= 5 and x <= 20 and y == 14 and button == 1 then
  63.     term.setCursorPos(5, 14)
  64.     print ("- Shutdown")
  65.     sleep (0.2)
  66.     os.shutdown ()
  67.     end
  68.     end
  69.     end
  70.    
  71. start ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement