Advertisement
Guest User

1

a guest
Aug 29th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.03 KB | None | 0 0
  1. os.loadAPI("c")
  2.  
  3.  
  4. rednet.open("back")
  5. term.clear()
  6. term.setCursorPos(1,1)
  7. term.setTextColor(colors.orange)
  8. c.centerText("Wireless Power Control")
  9. term.setCursorPos(1,2)
  10. term.setTextColor(colors.white)
  11. print("AE Control: -")
  12. print("On / Off")
  13.  
  14. term.setCursorPos(15,2)
  15. print("Plaz Power :")
  16. term.setCursorPos(15,3)
  17. print("On / Off")
  18.  
  19. term.setCursorPos(1,5)
  20. print("Sus Power :")
  21. print("On / Off")
  22.  
  23. term.setCursorPos(13,5)
  24. print("- Kezza power:")
  25. term.setCursorPos(15,6)
  26. print("On / Off")
  27. term.setCursorPos(1,8)
  28. print("Share Power:-")
  29. term.setCursorPos(1,9)
  30. print("On / Off")
  31.  
  32. term.setCursorPos(15,9)
  33. print("On / Off")
  34. term.setCursorPos(15,8)
  35. print("Lights     : ")
  36.  
  37. term.setCursorPos(22,19)
  38. term.setTextColor(colors.orange)
  39. print("Exit")
  40. term.setCursorPos(1,19)
  41. print("Edit")
  42. term.setTextColor(colors.white)
  43. term.setCursorPos(1,11)
  44. term.setTextColor(colors.red)
  45. term.setBackgroundColor(colors.gray)
  46. c.centerText("  Press to update  ")
  47. term.setTextColor(colors.white)
  48. term.setBackgroundColor(colors.black)
  49. term.setCursorPos(1,13)
  50. print("Plaz status : ")
  51. term.setCursorPos(1,14)
  52. print("AE Status   : ")
  53. term.setCursorPos(1,15)
  54. print("Sus status  : ")
  55. term.setCursorPos(1,16)
  56. print("Shared Stat : ")
  57. term.setCursorPos(1,17)
  58. print("Kezza status: ")
  59. term.setCursorPos(1,18)
  60. print("Lights      : ")
  61.  
  62. while true do
  63. event, side, x, y = os.pullEvent("mouse_click")
  64. -- Lights
  65. if x >= 15 and x <= 17 and y == 9 then
  66.   rednet.send(91, "on")
  67.   term.setCursorPos(15,9)
  68.   term.setBackgroundColor(colors.green)
  69.   print("On")
  70.   term.setCursorPos(20,9)
  71.   term.setBackgroundColor(colors.black)
  72.   print("Off")
  73.   term.setCursorPos(14,18)
  74.   term.setTextColor(colors.green)
  75.   print(" Active  ")
  76.   term.setTextColor(colors.white)
  77.   elseif x >= 20 and x < 23 and y == 9 then
  78.   rednet.send(91, "off")
  79.   term.setCursorPos(15,9)
  80.   term.setBackgroundColor(colors.black)
  81.   print("On")
  82.   term.setBackgroundColor(colors.red)
  83.   term.setCursorPos(20,9)
  84.   print("Off")
  85.   term.setCursorPos(14,18)
  86.   term.setBackgroundColor(colors.black)
  87.   term.setTextColor(colors.red)
  88.   print(" Inactive")
  89.   term.setTextColor(colors.white)
  90.   term.setBackgroundColor(colors.black)
  91.   end
  92. -- shared power --
  93. if x >= 1 and x < 3 and y == 9 then
  94.   rednet.send(76, "on")
  95.   term.setCursorPos(1,9)
  96.   term.setBackgroundColor(colors.green)
  97.   print("On")
  98.   term.setCursorPos(6,9)
  99.   term.setBackgroundColor(colors.black)
  100.   term.setTextColor(colors.white)
  101.   print("Off")
  102.   term.setCursorPos(14,16)
  103.   term.setTextColor(colors.green)
  104.   term.setBackgroundColor(colors.black)
  105.   print(" Active  ")
  106.   term.setTextColor(colors.white)
  107. elseif x >= 6 and x< 9 and y == 9 then
  108.   rednet.send(76, "off")
  109.   term.setCursorPos(1,9)
  110.   term.setBackgroundColor(colors.black)
  111.   print("On")
  112.   term.setCursorPos(6,9)
  113.   term.setBackgroundColor(colors.red)
  114.   print("Off")
  115.   term.setCursorPos(14,16)
  116.   term.setTextColor(colors.red)
  117.   term.setBackgroundColor(colors.black)
  118.   print(" Inactive")
  119.   term.setTextColor(colors.white)
  120. end
  121. -- update button
  122. if x >= 4 and x <= 21 and y == 11 then
  123.   term.setCursorPos(3,11)
  124.   term.setBackgroundColor(colors.gray)
  125.   term.setTextColor(colors.red)
  126.   c.centerText("   Updating.....")
  127.   term.setBackgroundColor(colors.black)
  128.   rednet.send(71, "status")
  129.   id, msg = rednet.receive()
  130.     rednet.send(91, "status")
  131.     if id == 91 then
  132.       if msg == "true" then
  133.       term.setCursorPos(14,18)
  134.       term.setTextColor(colors.green)
  135.       print(" Active ")
  136.       term.setTextColor(colors.white)
  137.       term.setCursorPos(15,9)
  138.       term.setBackgroundColor(colors.green)
  139.       print("On")
  140.       term.setBackgroundColor(colors.black)
  141.       term.setCursorPos(20,9)
  142.       print("Off")
  143.     else
  144.       term.setCursorPos(15,9)
  145.       term.setBackgroundColor(colors.black)
  146.       term.setTextColor(colors.white)
  147.       print("On")
  148.       term.setCursorPos(20,9)
  149.       term.setBackgroundColor(colors.red)
  150.       print("Off")
  151.       term.setBackgroundColor(colors.black)
  152.       term.setTextColor(colors.red)
  153.       term.setCursorPos(14,18)
  154.       print(" Inactive")
  155.     end
  156.   end
  157.  
  158.   if id == 71 then
  159.     if msg == "true" then
  160.     term.setCursorPos(14,13)
  161.     term.setTextColor(colors.green)
  162.     print(" Active  ")
  163.     term.setCursorPos(15,3)
  164.     term.setTextColor(colors.white)
  165.     term.setBackgroundColor(colors.green)
  166.     print("On")
  167.     term.setCursorPos(20,3)
  168.     term.setBackgroundColor(colors.black)
  169.     print("Off")
  170.     term.setBackgroundColor(colors.black)
  171.     else
  172.     term.setCursorPos(14,13)
  173.     term.setTextColor(colors.red)
  174.     print(" Inactive")
  175.     term.setTextColor(colors.white)
  176.     term.setBackgroundColor(colors.red)
  177.     term.setCursorPos(20,3)
  178.     print("Off")
  179.     term.setCursorPos(15,3)
  180.     term.setBackgroundColor(colors.black)
  181.     print("On")
  182.     term.setBackgroundColor(colors.black)
  183.     end
  184.   end
  185.   sleep(0.5)
  186.   rednet.send(69, "status")
  187.   id, msg = rednet.receive()
  188.   if id == 69 then
  189.     if msg == "true" then
  190.       term.setCursorPos(14,14)
  191.       term.setTextColor(colors.green)
  192.       print(" Active  ")
  193.       term.setBackgroundColor(colors.green)
  194.       term.setTextColor(colors.white)
  195.       term.setCursorPos(1,3)
  196.       print("On")
  197.       term.setCursorPos(6,3)
  198.       term.setBackgroundColor(colors.black)
  199.       print("Off")    
  200.       else
  201.       term.setCursorPos(14,14)
  202.       term.setTextColor(colors.red)
  203.       print(" Inactive")
  204.       term.setBackgroundColor(colors.red)
  205.       term.setTextColor(colors.white)
  206.       term.setCursorPos(6,3)
  207.       print("Off")
  208.       term.setCursorPos(1,3)
  209.       term.setBackgroundColor(colors.black)
  210.       print("On")
  211.      end
  212.   end
  213.   sleep(.5)
  214.   rednet.send(72, "status")
  215.   id, msg = rednet.receive()
  216.   if id == 72 then
  217.     if msg == "true" then
  218.       term.setCursorPos(14,15)
  219.       term.setTextColor(colors.green)
  220.       print(" Active  ")
  221.       term.setBackgroundColor(colors.green)
  222.       term.setTextColor(colors.white)
  223.       term.setCursorPos(1,6)
  224.       print("On")
  225.       term.setCursorPos(6,6)
  226.       term.setBackgroundColor(colors.black)
  227.       print("Off")
  228.       else
  229.       term.setCursorPos(14,15)
  230.       term.setTextColor(colors.red)
  231.       print(" Inactive")
  232.       term.setBackgroundColor(colors.red)
  233.       term.setTextColor(colors.white)
  234.       term.setCursorPos(6,6)
  235.       print("Off")
  236.       term.setCursorPos(1,6)
  237.       term.setBackgroundColor(colors.black)
  238.       print("On")
  239.     end
  240.   end
  241.   sleep(.5)
  242.   rednet.send(73, "status")
  243.   id, msg = rednet.receive()
  244.   if id == 73 then
  245.     if msg == "true" then
  246.       term.setCursorPos(14,17)
  247.       term.setTextColor(colors.green)
  248.       print(" Active  ")
  249.       term.setBackgroundColor(colors.green)
  250.       term.setTextColor(colors.white)
  251.       term.setCursorPos(15,6)
  252.       print("On")
  253.       term.setCursorPos(20,6)
  254.       term.setBackgroundColor(colors.black)
  255.       print("Off")
  256.       else
  257.       term.setCursorPos(14,17)
  258.       term.setTextColor(colors.red)
  259.       print(" Inactive")
  260.       term.setBackgroundColor(colors.red)
  261.       term.setTextColor(colors.white)
  262.       term.setCursorPos(20,6)
  263.       print("Off")
  264.       term.setCursorPos(15,6)
  265.       term.setBackgroundColor(colors.black)
  266.     end
  267.   end
  268.   sleep(.3)
  269.   rednet.send(76, "status")
  270.   id, msg = rednet.receive()
  271.   if msg == "true" then
  272.     term.setCursorPos(14,16)
  273.     term.setTextColor(colors.green)
  274.     print(" Active  ")
  275.     term.setBackgroundColor(colors.green)
  276.     term.setTextColor(colors.white)
  277.     term.setCursorPos(1,9)
  278.     term.setBackgroundColor(colors.green)
  279.     print("On")
  280.     term.setCursorPos(6,9)
  281.     term.setBackgroundColor(colors.black)
  282.     print("Off")
  283.     elseif msg == "false" then
  284.     term.setCursorPos(14,16)
  285.     term.setTextColor(colors.red)
  286.     print(" Inactive")
  287.     term.setBackgroundColor(colors.red)
  288.     term.setTextColor(colors.white)
  289.     term.setCursorPos(6,9)
  290.     term.setBackgroundColor(colors.red)
  291.     print("Off")
  292.     term.setCursorPos(1,9)
  293.     term.setBackgroundColor(colors.black)
  294.     print("On")
  295.   end
  296.   term.setCursorPos(3,11)
  297.   term.setBackgroundColor(colors.gray)
  298.   term.setTextColor(colors.red)
  299.   c.centerText("  Press to Update  ")
  300.   term.setTextColor(colors.white)
  301.   term.setBackgroundColor(colors.black)
  302. end
  303.  
  304. if x >= 22 and x < 26 and y == 19 then
  305.   term.clear()
  306.   break
  307. end
  308. if x >= 1 and x < 4 and y == 19 then
  309.   shell.run("edit 1")
  310.   os.reboot()
  311. end
  312.  
  313. if x >= 1 and x < 10 and y == 14 then
  314.   rednet.send(71, "status")
  315.  id, msg = rednet.receive()
  316.   if id == 71 then
  317.  
  318.   if msg == "true" then
  319.     term.setCursorPos(14,14)
  320.     term.setBackgroundColor(colors.green)
  321.     print(" Active ")
  322.     term.setCursorPos(15,14)
  323.   else
  324.     term.setCursorPos(14,14)
  325.     term.setBackgroundColor(colors.red)
  326.     print("Inactive")
  327.   end
  328.  -- print(msg)
  329.   term.setBackgroundColor(colors.black)
  330.   end
  331. end
  332.  
  333. if x >= 1 and x < 10 and y == 15 then
  334.   rednet.send(69, "status")
  335.   id, msg = rednet.receive()
  336.   if id == 69 then
  337.   if msg == "true" then
  338.   term.setCursorPos(14,15)
  339.   term.setBackgroundColor(colors.green)
  340.   print(" Active ")
  341.   else
  342.    term.setCursorPos(14,15)
  343.    term.setBackgroundColor(colors.red)
  344.    print("Inactive")
  345.   end
  346.  -- print(msg)
  347.   --term.setBackgroundColor(colors.black)
  348.   end  
  349. end
  350.  
  351. if x >= 1 and x < 10 and y == 16 then
  352.   rednet.send(72, "status")
  353.   id, msg = rednet.receive()  
  354.   if id == 72 then
  355.     if msg == "true" then
  356.     term.setCursorPos(14,16)
  357.     term.setBackgroundColor(colors.green)  
  358.     print(" Active ")
  359.     else
  360.     term.setCursorPos(14,16)
  361.     term.setBackgroundColor(colors.red)
  362.     print("Inactive")
  363.     end
  364.  end
  365. end  
  366.  
  367. if x >= 1 and x < 10 and y == 17 then
  368.   rednet.send(73, "status")
  369.   id, msg = rednet.receive()    
  370.   if id == 73 then
  371.   if msg == "true" then
  372.     term.setCursorPos(14,17)
  373.     term.setBackgroundColor(colors.green)
  374.     print(" Active ")
  375.   else
  376.     term.setCursorPos(14,17)
  377.     term.setBackgroundColor(colors.red)
  378.     print("Inactive")
  379.   end
  380.     --term.setBackgroundColor(colors.black)
  381.   end
  382. end
  383. -- AE
  384. if x >= 1 and x < 3 and y == 3 then
  385.   term.setCursorPos(1,3)
  386.   term.setBackgroundColor(colors.lime)
  387.   print("On")
  388.   term.setCursorPos(6,3)
  389.   term.setBackgroundColor(colors.black)
  390.   print("Off")
  391.   rednet.send(69, "on")
  392.   term.setCursorPos(14,14)
  393.   term.setBackgroundColor(colors.black)
  394.   term.setTextColor(colors.green)
  395.   print(" Active  ")
  396.   term.setTextColor(colors.white)
  397.  
  398. end
  399.  
  400. if x > 4 and x < 9 and y == 3 then
  401.   rednet.send(69, "off")
  402.   term.setCursorPos(1,3)
  403.   term.setBackgroundColor(colors.black)
  404.   print("On ")
  405.   term.setCursorPos(6,3)
  406.   term.setBackgroundColor(colors.red)
  407.   print("Off")
  408.   term.setCursorPos(14,14)
  409.   term.setTextColor(colors.red)
  410.   term.setBackgroundColor(colors.black)
  411.   print(" Inactive")
  412.   term.setTextColor(colors.white)
  413. end
  414. -- Plaz Power
  415. if x > 15 and x <17 and y == 3 then
  416.   rednet.send(71, "on")
  417.   term.setCursorPos(15,3)
  418.   term.setBackgroundColor(colors.lime)
  419.   print("On")
  420.   term.setCursorPos(20,3)
  421.   term.setBackgroundColor(colors.black)
  422.   print("Off")
  423.   term.setCursorPos(14,13)
  424.   term.setBackgroundColor(colors.black)
  425.   term.setTextColor(colors.green)
  426.   print(" Active  ")
  427.   term.setTextColor(colors.white)
  428. end
  429. if x > 20 and x < 27 and y == 3 then
  430.   rednet.send(71, "off")
  431.   term.setCursorPos(15,3)
  432.   term.setBackgroundColor(colors.black)
  433.   print("On")
  434.   term.setCursorPos(20,3)
  435.   term.setBackgroundColor(colors.red)
  436.   print("Off")
  437.   term.setCursorPos(14,13)
  438.   term.setBackgroundColor(colors.black)
  439.   term.setTextColor(colors.red)
  440.   print(" Inactive")
  441.   term.setTextColor(colors.white)
  442. end
  443. -- Sus Power --
  444. if x >= 1 and x < 3 and y == 6 then
  445.   rednet.send(72, "on")
  446.   term.setCursorPos(1,6)
  447.   term.setBackgroundColor(colors.lime)
  448.   print("On")
  449.   term.setCursorPos(6,6)
  450.   term.setBackgroundColor(colors.black)
  451.   print("Off")
  452.   term.setCursorPos(14,15)
  453.   term.setBackgroundColor(colors.black)
  454.   term.setTextColor(colors.green)
  455.   print(" Active  ")
  456.   term.setTextColor(colors.white)
  457. end
  458.  
  459. if x >= 6 and x < 9 and y == 6 then
  460.   rednet.send(72, "off")
  461.   term.setCursorPos(1,6)
  462.   term.setBackgroundColor(colors.black)
  463.   print("On")
  464.   term.setCursorPos(6,6)
  465.   term.setBackgroundColor(colors.red)
  466.   print("Off")
  467.   term.setCursorPos(14,15)
  468.   term.setBackgroundColor(colors.black)
  469.   term.setTextColor(colors.red)
  470.   print(" Inactive")
  471.   term.setTextColor(colors.white)
  472. end
  473.  
  474. if x >= 15 and x < 16 and y == 6 then
  475.   rednet.send(73, "on")
  476.   term.setCursorPos(15,6)
  477.   term.setBackgroundColor(colors.lime)
  478.   print("On")
  479.   term.setCursorPos(20,6)
  480.   term.setBackgroundColor(colors.black)
  481.   print("Off")
  482.   term.setCursorPos(14,17)
  483.   term.setBackgroundColor(colors.black)
  484.   term.setTextColor(colors.green)
  485.   print(" Active  ")
  486.   term.setTextColor(colors.white)
  487. end
  488.  
  489. if x >= 20 and x < 24 and y == 6 then
  490.   rednet.send(73, "off")
  491.   term.setCursorPos(15,6)
  492.   term.setBackgroundColor(colors.black)
  493.   print("On")
  494.   term.setCursorPos(20,6)
  495.   term.setBackgroundColor(colors.red)
  496.   print("Off")
  497.   term.setCursorPos(14,17)
  498.   term.setBackgroundColor(colors.black)
  499.   term.setTextColor(colors.red)
  500.   print(" Inactive")
  501.   term.setTextColor(colors.white)
  502. end
  503. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement