Advertisement
Guest User

startup

a guest
Nov 15th, 2019
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.31 KB | None | 0 0
  1. modemC = peripheral.wrap('top') --cable
  2. modemW = peripheral.wrap('left')--wifi
  3.  
  4.  
  5. modemW.open(51)
  6.  
  7.  
  8. EUn1 = 0
  9. EUn2 = 0
  10. RFn1 = 0
  11. RFn2 = 0
  12. EU2n1 = 0
  13. EU2n2 = 0
  14. RF2n1 = 0
  15. RF2n2 = 0
  16. moni = peripheral.wrap("monitor_4")
  17. moni.setBackgroundColor(colors.black)
  18. moni.setTextScale(1)
  19. mfe = nil
  20. mfe2 = nil
  21. mfeMax = nil
  22. mfe2Max = nil
  23. cube2 = nil
  24. cube = nil
  25. cubeMax = nil
  26. cube2Max = nil
  27.  
  28. function recevoir()
  29.  
  30. e, s, frequency, reply, m, d = os.pullEvent("modem_message")
  31. if frequency == 51 then
  32. if reply == 52 then
  33. RFStored = m
  34. elseif reply == 53 then
  35. RF2Stored = m
  36. elseif reply == 54 then
  37. EUStored = m
  38. elseif reply == 55 then
  39. EU2Stored = m
  40. elseif reply == 56 then
  41. cubeMax = m
  42. elseif reply == 57 then
  43. cube2Max = m
  44. elseif reply == 58 then
  45. mfeMax = m
  46. elseif reply == 59 then
  47. mfe2Max = m
  48. end
  49.  
  50. end
  51.  
  52. end
  53.  
  54.  
  55. function quelColor(energy)
  56. if energy < 20 then c = colors.red end
  57. if energy >20 and energy < 70 then c = colors.yellow end
  58. if energy > 70 then c = colors.green  end
  59. return(c)
  60. end
  61.  
  62. function titre (x,y,titre,c)
  63. moni.setTextColor(c)
  64. moni.setCursorPos(x,y)
  65. moni.write (titre)
  66. end
  67.  
  68. function etat (x,y,n1,n2)
  69. e = (n1 - n2)/100
  70. e = math.floor (e)/10
  71. if e < 0 then c = colors.red
  72. else c = colors.green end
  73. moni.setTextColor(c)
  74. moni.setCursorPos(x,y)
  75. moni.write (e)
  76. moni.write ('K')
  77. end
  78.  
  79. function barre (x,y,ener,col)
  80. moni.setCursorPos(x,y)
  81. I = ener /8
  82. for i =1,I do
  83. moni.setBackgroundColor(col)
  84. moni.write(" ")
  85. end
  86. moni.setBackgroundColor(colors.black)
  87. end
  88.  
  89.  
  90. while true do
  91. recevoir()
  92. if EUStored ~= nil and mfeMax ~= nil then
  93. EU = math.floor(((EUStored ) / mfeMax ) *1000)/10
  94. EUn1 = EUStored
  95. end
  96. if EU2Stored ~= nil and mfe2Max ~= nil then
  97. EU2 = math.floor(((EU2Stored ) / mfe2Max ) *1000)/10
  98. EU2n1 = EU2Stored
  99. end
  100. if RFStored ~= nil and cubeMax ~= nil then
  101. RF = math.floor((RFStored / cubeMax ) *1000)/10
  102. RFn1 = RFStored
  103. end
  104. if RF2Stored ~= nil and cube2Max ~= nil then
  105. RF2 = math.floor((RF2Stored / cube2Max ) *1000)/10
  106. RF2n1 = RF2Stored
  107. end
  108.  
  109. moni.clear()
  110. titre(4,1,"Monitoring -> The Sentry",colors.yellow)
  111. titre(2,3,"RF Principal",colors.white)
  112. titre(2,8,"RF Secondaire",colors.white)
  113. titre(16,3,"EU Principal",colors.white)
  114. titre (16,8,"EU Secondaire",colors.white)
  115.  
  116.  
  117. if EU ~= nil then
  118. titre(20,4,EU,quelColor(EU))
  119. moni.write("%")
  120. barre(16,5,EU,quelColor(EU))
  121. etat(19,6,EUn1,EUn2)
  122. else
  123. titre (18,4,"indisponible",colors.red)
  124. titre (18,5,"indisponible",colors.red)
  125. titre (18,6,"indisponible",colors.red)
  126. end
  127.  
  128. if EU2 ~= nil then
  129. titre(20,9,EU2,quelColor(EU2))
  130. moni.write("%")
  131. barre(16,10,EU2,quelColor(EU2))
  132. etat(19,11,EU2n1,EU2n2)
  133. else
  134. titre (18,9,"indisponible",colors.red)
  135. titre (18,10,"indisponible",colors.red)
  136. titre (18,11,"indisponible",colors.red)
  137. end
  138.  
  139. if RF ~= nil then
  140. titre(6,4,RF,quelColor(RF))
  141. moni.write("%")
  142. barre(2,5,RF,quelColor(RF))
  143. etat(5,6,RFn1,RFn2)
  144. else
  145. titre (3,4,"indisponible",colors.red)
  146. titre (3,5,"indisponible",colors.red)
  147. titre (3,6,"indisponible",colors.red)
  148. end
  149.  
  150. if RF2 ~= nil then
  151. titre(6,9,RF2,quelColor(RF2))
  152. moni.write("%")
  153. barre(2,10,RF2,quelColor(RF2))
  154. etat(5,11,RF2n1,RF2n2)
  155. else
  156. titre (3,9,"indisponible",colors.red)
  157. titre (3,10,"indisponible",colors.red)
  158. titre (3,11,"indisponible",colors.red)
  159. end
  160.  
  161. moni.setBackgroundColor(colors.black)
  162. EUn2 = EUn1
  163. EU2n2 = EU2n1
  164. RFn2 = RFn1
  165. RF2n2 = RF2n1
  166.  
  167.  
  168. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement