Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- red = colors.red
- yellow = colors.yellow
- green = colors.green
- black = colors.black
- white = colors.white
- orange = colors.orange
- blue = colors.blue
- modemW = peripheral.wrap('right')--wifi
- modemW.open(61)
- moni = peripheral.wrap("monitor_10")
- moni.setBackgroundColor(black)
- moni.setTextScale(1)
- moni12 = peripheral.wrap("monitor_12")
- moni12.setBackgroundColor(black)
- moni12.setTextScale(4)
- moni11 = peripheral.wrap("monitor_11")
- moni11.setBackgroundColor(black)
- moni11.setTextScale(4)
- etat_energy,etat_lux,etat_porte,etat_securite = false,false,false,false
- moni.setTextScale(1)
- chan = 61
- sto = fs.open("DEFCON", "r")
- DEFCON = tonumber(sto.readLine())
- sto.close()
- function recevoir()
- e, s, frequency, reply, m, d = os.pullEvent("modem_message")
- if frequency == 61 then
- if reply == 62 then
- etat_porte = m
- elseif reply == 63 then
- etat_lux = m
- elseif reply == 64 then
- etat_energy = m
- elseif reply == 65 then
- etat_securite = m
- elseif reply == 66 then
- DEFCON = m
- elseif reply == 67 then
- --cube2Max = m
- elseif reply == 68 then
- --mfeMax = m
- elseif reply == 69 then
- --mfe2Max = m
- end
- end
- end
- function emet()
- while true do
- modemW.transmit(61,66,DEFCON)
- sleep(20)
- end
- end
- function titre (x,y,titre,c)
- moni.setTextColor(c)
- moni.setCursorPos(x,y)
- moni.write (titre)
- end
- function barre (x,y,pourcent,col)
- moni.setCursorPos(x,y)
- I = pourcent /10
- for i =1,I do
- moni.setBackgroundColor(col)
- moni.write(" ")
- end
- moni.setBackgroundColor(black)
- end
- function defcon (mon,DEFCON)
- mon.clear()
- o = 1
- for i = 1,5 do
- mon.setTextColor(white)
- mon.setCursorPos(1,i)
- if i == DEFCON then
- if DEFCON == 5 then
- def = blue
- elseif DEFCON == 4 then def = green
- elseif DEFCON == 3 then def = yellow
- elseif DEFCON == 2 then def = red
- elseif DEFCON == 1 then
- def = white
- mon.setTextColor(black)
- end
- mon.setBackgroundColor(def)
- mon.write("D")
- mon.write(o)
- mon.setBackgroundColor(black)
- mon.setTextColor(white)
- else
- mon.write("D")
- mon.write(o)
- end
- o = o +1
- end
- mon.setBackgroundColor(black)
- end
- while true do
- moni.clear()
- if DEFCON == 1 then etat_porte = " Acces refusé"
- elseif DEFCON == 2 then etat_porte = " Acces restrein"
- elseif DEFCON == 3 then etat_porte = " Acces surveillé"
- elseif DEFCON == 4 then etat_porte = " Acces libre"
- end
- defcon (moni12,DEFCON)
- defcon (moni11,DEFCON)
- titre(10,1,"The security",yellow)
- titre (2,3,"acces principal :",yellow)
- moni.setCursorPos(2,4)
- if etat_porte == false then
- moni.setTextColor(red)
- moni.write(" Offline")
- elseif etat_porte == " Acces libre" or etat_porte == " Acces surveillé" then
- moni.setTextColor(green)
- moni.write(etat_porte)
- else
- moni.setTextColor(orange)
- moni.write(etat_porte)
- end
- titre(2,6,"éclairage :",yellow)
- if etat_lux == false then
- moni.setTextColor(red)
- moni.write(" Offline") end
- titre(2,8,"energy HUB :",yellow)
- if etat_lux == false then
- moni.setTextColor(red)
- moni.write(" Offline") end
- titre(2,10,"securité HUB :",yellow)
- if etat_securite == false then
- moni.setTextColor(red)
- moni.write(" Offline") end
- parallel.waitForAny(recevoir, emet)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement