fantadada

ecran_cell

Apr 17th, 2022 (edited)
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. ---V1----
  2. rednet.open("top")
  3. m = peripheral.wrap("right")
  4. Sx, Sy = m.getSize()
  5. m.clear()
  6.  
  7.  
  8.  
  9. local function Calcul(X, Y)
  10.     return  X-4, Y-2
  11. end
  12.  
  13.  
  14. local function Affichage(Cell_name, numcell, Verite)
  15.     if type(Cell_name) ~= "string" then error("Invalide str") return end
  16.     if numcell < 1 then error("Invalide numero cell") return end
  17.     local Sx_u, Sy_u = Calcul(Sx,Sy)
  18.    
  19.     if i == 1 then
  20.         m.setTextColor(colors.white)
  21.         m.setCursorPos(Sx - Sx_u,Sy - Sy_u)
  22.         m.write("Cell "..Cell_name..":")
  23.         if Verite then
  24.             m.setCursorPos(Sx - Sx_u + 9,Sy - Sy_u)
  25.             m.setTextColor(colors.green)
  26.             m.write("HIGH")
  27.         end
  28.     else
  29.         m.setTextColor(colors.white)
  30.         m.setCursorPos(Sx - Sx_u,Sy-Sy_u+numcell-1)
  31.         m.write("Cell "..Cell_name..":")
  32.         if Verite then
  33.             m.setCursorPos(Sx - Sx_u + 9,Sy-Sy_u+numcell-1)
  34.             m.setTextColor(colors.green)
  35.             m.write("HIGH")
  36.         end
  37.  
  38.     end
  39.  
  40. end
  41.  
  42. local function Activate(numcell, msg_red, msg_sh,msg_shok,Valeur)
  43.     local Sx_u, Sy_u = Calcul(Sx,Sy)
  44.     if msg_red == msg_sh or Valeur == msg_sh then
  45.         if numcell == 1 then
  46.             m.setCursorPos(Sx - Sx_u + 9,Sy - Sy_u)
  47.         else          
  48.             m.setCursorPos(Sx - Sx_u + 9,Sy - Sy_u+numcell-1)
  49.         end
  50.         m.setTextColor(colors.red)
  51.         m.write("LOW")
  52.         return false
  53.     elseif msg_red == msg_shok or Valeur == msg_shok then
  54.         return true
  55.     else
  56.         return true
  57.     end
  58.  
  59. end
  60.  
  61.  
  62. m.clear()
  63. Affichage("AE",1, true)
  64. Affichage("Eg",2,true)
  65. local V_A, V_E = ""
  66. while true do
  67.     local event, Sendid, msg = os.pullEvent("rednet_message")
  68.     m.clear()
  69.     if msg == "LowBat_AE" or msg == "Ok_AE" then V_A = msg end
  70.     if msg == "LowBat_Eg" or msg == "Ok_Eg" then V_E = msg end
  71.     Affichage("AE",1,Activate(1,msg,"LowBat_AE","Ok_AE",V_A))
  72.     Affichage("Eg",2,Activate(2,msg,"LowBat_Eg","OK_Eg",V_E))
  73.  
  74. end
  75.  
  76.  
  77.  
Add Comment
Please, Sign In to add comment