Advertisement
pepeknamornik

bluescreen

Jun 18th, 2015
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 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.black)
  29.     term.setTextColor(colors.red)
  30.     term.clear()
  31.     prc ("Pepdroll has Crashed!", 2)
  32.     prc ("Select the next step", 5)
  33.     term.setTextColor(colors.white)
  34.     term.setCursorPos(5, 10)
  35.     print ("- Commander")
  36.     term.setCursorPos(5, 12)
  37.     print ("- Reboot")
  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 == 10 and button == 1 then
  47.     term.setBackgroundColor(colors.black)
  48.     term.setTextColor(colors.white)
  49.     term.clear()
  50.     term.setCursorPos(5, 10)
  51.     print ("- Commander")
  52.     sleep (0.2)
  53.     term.clear()
  54.     local data = fs.open ("/system/RAM/ercommander", "w")
  55.         data.close ()
  56.     term.setCursorPos(1,1)
  57.     shell.run ("/system/api/commander")
  58.     elseif x >= 5 and x <= 20 and y == 12 and button == 1 then
  59.     term.setCursorPos(5, 12)
  60.     print ("- Reboot")
  61.     sleep (0.2)
  62.     os.reboot ()
  63.     elseif x >= 5 and x <= 20 and y == 14 and button == 1 then
  64.     term.setCursorPos(5, 14)
  65.     print ("- Shutdown")
  66.     sleep (0.2)
  67.     os.shutdown ()
  68.     end
  69.     end    
  70.     end
  71.    
  72. start ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement