Guest User

Untitled

a guest
Feb 27th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.84 KB | None | 0 0
  1. -- Desktop
  2. slc = 0
  3. tBarC = 8
  4. tBartC = 1
  5. backColor = 1
  6. term.setBackgroundColor(backColor)
  7. term.clear()
  8.  
  9. -- Functions
  10. function titleBar()
  11.   term.setCursorPos(1,1)
  12.   term.setBackgroundColor(tBarC)
  13.   term.setTextColor(tBartC)
  14.   term.clearLine()
  15.   term.setCursorPos(2, 1)
  16.   print("[Start Menu]")
  17.   term.setCursorPos(15, 1)
  18.   print("Reactor Commands")
  19. end
  20.  
  21. function drawDesktop()
  22.   term.setBackgroundColor(backColor)
  23.   term.clear()
  24.   bground = paintutils.loadImage(".background")
  25.   paintutils.drawImage(bground,1,1)
  26.   titleBar()
  27. end
  28.  
  29. function drawMenu1()
  30.   term.setTextColor(256)
  31.   term.setBackgroundColor(128)
  32.   term.setCursorPos(1,2)
  33.   print("           ")
  34.   term.setCursorPos(1,3)
  35.   print(" Shutdown ")
  36.   term.setCursorPos(1,4)
  37.   print(" Restart  ")
  38.   term.setCursorPos(1,5)
  39.   print("           ")
  40. end
  41.  
  42. function drawMenu2()
  43.   term.setTextColor(256)
  44.   term.setBackgroundColor(128)
  45.   term.setCursorPos(15,2)
  46.   print("                    ")
  47.   term.setCursorPos(15,3)
  48.   print(" Start Reactor ")
  49.   term.setCursorPos(15,4)
  50.   print(" Stop Reactor  ")
  51.   term.setCursorPos(15,5)
  52.   print(" Lock Room        ")
  53.   term.setCursorPos(15,6)
  54.   print("                    ")
  55. end
  56.  
  57. -- Main Loop
  58. drawDesktop()
  59. while true do
  60.   local event, arg1, arg2, arg3 = os.pullEvent()
  61.  
  62.   if event == "mouse_click" then
  63.  
  64.     if slc == 0 then
  65.       if event == "mouse_click" then
  66.         if arg2 >=2 and arg2 <=15 and arg3==1 and arg1 ==1 then
  67.           drawMenu1()
  68.           slc = 1
  69.         elseif arg2 >=15 and arg2 <=30 and arg3==1 and arg1 ==1 then
  70.           drawMenu2()
  71.           slc = 1
  72.         else
  73.           drawDesktop()
  74.         end
  75.       end
  76.     elseif slc == 1 then
  77.       if event == "mouse_click" then
  78.         if arg2 >=1 and arg2 <=11 and arg1 == 1 and arg3== 3 then
  79.           slc = 0
  80.           os.shutdown()
  81.         elseif arg2>=1 and arg2<=11 and arg3==4 and arg1 ==1 then
  82.           slc = 0
  83.           os.reboot()
  84.         elseif arg2>=15 and arg2<=25 and arg3==3 and arg1 ==1 then
  85.           slc = 0
  86.           rednet.open("top")
  87.           rednet.broadcast("Reactor 1 On")
  88.           rednet.close("top")
  89.           rs.setOutput("back", true)
  90.         elseif arg2>=15 and arg2<=25 and arg3==4 and arg1 ==1 then
  91.           slc = 0
  92.           rednet.open("top")
  93.           rednet.broadcast("Reactor 1 Off")
  94.           rednet.close("top")
  95.           rs.setOutput("back", false)
  96.         elseif arg2>=15 and arg2<=20 and arg3==5 and arg1 ==1 then
  97.           slc = 0
  98.           os.shutdown()
  99.         else
  100.           slc = 0
  101.           drawDesktop()
  102.         end
  103.       end
  104.     end
  105.      
  106.   elseif event == "rednet_message" and arg2 == "Reactor 1 Overheat" then
  107.  
  108.     rs.setOutput("back", false)
  109.     rednet.open("top")
  110.     rednet.broadcast("Reactor 1 Off")
  111.     rednet.close("top")
  112.    
  113.   else
  114.  
  115.     drawDesktop()
  116.    
  117.   end
  118. end
Advertisement
Add Comment
Please, Sign In to add comment