Advertisement
FoxWorn3365

Sistema reattore nucleare

Jul 31st, 2022 (edited)
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Made by FoxWorn3365
  2. term.setBackgroundColor(colors.white)
  3. term.clear()
  4.  
  5. -- Sistemo le funzioni
  6. function header(lol)
  7.     term.setBackgroundColor(colors.lightBlue)
  8.     term.setTextColor(colors.white)
  9.     term.setCursorPos(16, 1)
  10.     print(lol)
  11. end
  12.  
  13. function button(x, y, text, color)
  14.    term.setBackgroundColor(colors[color])
  15.    term.setTextColor(colors.white)
  16.    term.setCursorPos(x, y)
  17.    print(text)
  18. end
  19.  
  20. function sotText(x, y, tex, col, bkcol)
  21.    term.setBackgroundColor(colors[bkcol])
  22.    term.setTextColor(colors[col])
  23.    term.setCursorPos(x, y)
  24.    print(tex)
  25.    term.setBackgroundColor(colors.white)
  26. end
  27.  
  28. function ntext(x, y, text, col)
  29.    term.setBackgroundColor(colors.white)
  30.    term.setTextColor(colors[col])
  31.    term.setCursorPos(x, y)
  32.    print(text)
  33. end
  34.  
  35. function n(ca)
  36.    term.setBackgroundColor(colors.white)
  37.    term.setTextColor(colors[ca])
  38. end
  39.  
  40. function reactorSend(id, msg)
  41.    rednet.send(id, msg)
  42. end
  43.  
  44. function allarme(nun)
  45.    if nun == 1 then
  46.    sotText(5, 14, "! TEMPERATURA REATTORE SUPERIORE DI 1000C", "white", "red")
  47.    n("blue")
  48.    elseif nun == 2 then
  49.    sotText(5, 15, "! TEMPERATURA REATTORE SUPERIORE DI 8500C", "white", "red")
  50.    n("blue")
  51.    elseif nun == 3 then
  52.    sotText(5, 16, "! TEMPERATURA REATTORE SUPERIORE DI 5000C OFF", "white", "yellow")
  53.    n("blue")
  54.    elseif nun == 4 then
  55.    sotText(5, 17, "! TEMPERATURA REATTORE SUPERIORE DI 5000C", "white", "orange")
  56.    n("blue")
  57.    elseif nun == 5 then
  58.    sotText(5, 18, "! OUTPUT INFERIORE A 250kW", "white", "green")
  59.    n("blue")
  60.    end
  61. end
  62.  
  63. -- Immeto i dati per configurare
  64. reactorName = "RBMK-1"
  65. emergency = "right"
  66.  
  67. -- Sistemo qualche variabile d'ambiente
  68. alarmHeat0 = true
  69. alarmHeat1 = true
  70. alarmHeat2 = true
  71. alarmOutput = true
  72.  
  73. -- Inizio il programma
  74. while true do -- Il while servir�AF�BF�BDA0 per tenere sempre aggiornati i dati
  75. -- Recupero i dati del reattore
  76. term.clear()
  77. p = peripheral.wrap("bottom")
  78. local a, b, c, t = p.get(1)
  79.  
  80. heat = t.heat
  81. status = t.reactorPoweredB
  82. mheat = t.maxHeat
  83. output = t.output
  84.  
  85. -- Elaboro alcune informazioni
  86. if status == true then
  87.    statusColor = "green"
  88.    statusText = "ATTIVO"
  89. else
  90.    statusColor = "red"
  91.    statusText = "DISATTIVO"
  92. end
  93.  
  94. if heat <= 1000 then
  95.    heatColor = "green"
  96.    alarmHeat0 = false
  97.    alarmHeat1 = false
  98.    alarmHeat2 = false
  99.    rs.setOutput(emergency, false)
  100. elseif heat > 1000 and heat < 5000 then
  101.    heatColor = "yellow"
  102.    alarmHeat0 = true
  103.    rs.setOutput(emergency, false)
  104. elseif heat > 5000 and heat < 8500 then
  105.    heatColor = "orange"
  106.    alarmHeat1 = true
  107.    rs.setOutput(emergency, false)
  108. elseif heat > 8500 then
  109.    alarmHeat2 = true
  110.    heatColor = "red"
  111.    rs.setOutput(emergency, true)
  112. end
  113.  
  114. if output <= 250 then
  115.    outputColor = "orange"
  116. elseif output >= 251 and output <= 500 then
  117.    outputColor = "yellow"
  118. else
  119.    outputColor = "green"
  120. end
  121.  
  122. if heat > 5000 and status == false then
  123.    alarmStatus = true
  124. else
  125.    alarmStatus = false
  126. end
  127.  
  128. if output < 250 then
  129.    alarmOutput = true
  130. else
  131.    alarmOutput = false
  132. end
  133.  
  134. -- Inizio l'interfaccia utente
  135. header("GESTIONE REATTORE RBMK")
  136. n("black")
  137. print("\nBenvenuto nel pannello di gestione del reattore "..reactorName)
  138. print("\n---------------------------------------")
  139. n("blue")
  140. print("\nStato Reattore:")
  141. ntext(17, 8, statusText, statusColor)
  142. n("blue")
  143. print("Temperatura:")
  144. ntext(14, 9, heat, heatColor)
  145. ntext(20, 9, " / "..mheat, "black")
  146. print("Output:")
  147. ntext(9, 10, output.."kW", outputColor)
  148.  
  149. n("blue")
  150. ntext(5, 12, "ALLARMI", "red")
  151. if alarmHeat0 == true then
  152.    allarme(1)
  153. end
  154.  
  155. if alarmHeat1 == true then
  156.    allarme(2)
  157. end
  158.  
  159. if alarmHeat2 == true then
  160.    allarme(3)
  161. end
  162.  
  163. if alarmStatus == true then
  164.    allarme(4)
  165. end
  166.  
  167. if alarmOutput == true then
  168.    allarme(5)
  169.    term.setBackgroundColor(colors.white)
  170. end
  171.  
  172. n("blue")
  173. sleep(1)
  174. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement