Advertisement
Guest User

startup

a guest
Nov 17th, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.10 KB | None | 0 0
  1. red = colors.red
  2. yellow = colors.yellow
  3. green = colors.green
  4. black = colors.black
  5. white = colors.white
  6. orange = colors.orange
  7. blue = colors.blue
  8.  
  9. modemW = peripheral.wrap('right')--wifi
  10. modemW.open(61)
  11. moni = peripheral.wrap("monitor_10")
  12. moni.setBackgroundColor(black)
  13. moni.setTextScale(1)
  14. moni12 = peripheral.wrap("monitor_12")
  15. moni12.setBackgroundColor(black)
  16. moni12.setTextScale(4)
  17. moni11 = peripheral.wrap("monitor_11")
  18. moni11.setBackgroundColor(black)
  19. moni11.setTextScale(4)
  20. etat_energy,etat_lux,etat_porte,etat_securite = false,false,false,false
  21.  
  22. moni.setTextScale(1)
  23. chan = 61
  24.  
  25. sto = fs.open("DEFCON", "r")
  26.  
  27. DEFCON = tonumber(sto.readLine())
  28. sto.close()
  29.  
  30.  
  31. function recevoir()
  32.  
  33. e, s, frequency, reply, m, d = os.pullEvent("modem_message")
  34. if frequency == 61 then
  35. if reply == 62 then
  36. etat_porte = m
  37. elseif reply == 63 then
  38. etat_lux = m
  39. elseif reply == 64 then
  40. etat_energy = m
  41. elseif reply == 65 then
  42. etat_securite = m
  43. elseif reply == 66 then
  44. DEFCON = m
  45. elseif reply == 67 then
  46. --cube2Max = m
  47. elseif reply == 68 then
  48. --mfeMax = m
  49. elseif reply == 69 then
  50. --mfe2Max = m
  51. end
  52.  
  53. end
  54.  
  55. end
  56.  
  57. function emet()
  58. while true do
  59. modemW.transmit(61,66,DEFCON)
  60.  
  61. sleep(20)
  62. end
  63. end
  64.  
  65. function titre (x,y,titre,c)
  66. moni.setTextColor(c)
  67. moni.setCursorPos(x,y)
  68. moni.write (titre)
  69. end
  70.  
  71.  
  72. function barre (x,y,pourcent,col)
  73. moni.setCursorPos(x,y)
  74. I = pourcent /10
  75. for i =1,I do
  76. moni.setBackgroundColor(col)
  77. moni.write(" ")
  78. end
  79. moni.setBackgroundColor(black)
  80. end
  81.  
  82. function defcon (mon,DEFCON)
  83. mon.clear()
  84. o = 1
  85. for i = 1,5  do
  86. mon.setTextColor(white)
  87. mon.setCursorPos(1,i)
  88. if i == DEFCON then
  89. if DEFCON == 5 then
  90. def = blue
  91. elseif DEFCON == 4 then def = green
  92. elseif DEFCON == 3 then def = yellow
  93. elseif DEFCON == 2 then def = red
  94. elseif DEFCON == 1 then
  95. def = white
  96. mon.setTextColor(black)
  97. end
  98. mon.setBackgroundColor(def)
  99. mon.write("D")
  100. mon.write(o)
  101. mon.setBackgroundColor(black)
  102. mon.setTextColor(white)
  103. else
  104. mon.write("D")
  105. mon.write(o)
  106. end
  107. o =  o +1
  108. end
  109. mon.setBackgroundColor(black)
  110. end
  111.  
  112. while true do
  113. moni.clear()
  114.  
  115. if DEFCON == 1 then etat_porte = " Acces refusé"
  116. elseif DEFCON == 2 then etat_porte = " Acces restrein"
  117. elseif DEFCON == 3 then etat_porte = " Acces surveillé"
  118. elseif DEFCON == 4 then etat_porte = " Acces libre"
  119. end
  120.  
  121. defcon (moni12,DEFCON)
  122. defcon (moni11,DEFCON)
  123.  
  124. titre(10,1,"The security",yellow)
  125.  
  126. titre (2,3,"acces principal :",yellow)
  127. moni.setCursorPos(2,4)
  128. if etat_porte == false then
  129. moni.setTextColor(red)
  130.  moni.write(" Offline")
  131.  elseif etat_porte == " Acces libre" or etat_porte == " Acces surveillé" then
  132.  moni.setTextColor(green)
  133.  moni.write(etat_porte)
  134.  else
  135.  moni.setTextColor(orange)
  136.  moni.write(etat_porte)
  137.  end
  138.  
  139. titre(2,6,"éclairage :",yellow)
  140. if etat_lux == false then
  141. moni.setTextColor(red)
  142.  moni.write(" Offline") end
  143.  
  144.  titre(2,8,"energy HUB :",yellow)
  145. if etat_lux == false then
  146. moni.setTextColor(red)
  147.  moni.write(" Offline") end
  148.  
  149. titre(2,10,"securité HUB :",yellow)
  150. if etat_securite == false then
  151. moni.setTextColor(red)
  152.  moni.write(" Offline") end
  153.  
  154.  
  155.  
  156. parallel.waitForAny(recevoir, emet)
  157.  
  158.  
  159. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement