Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monit = peripheral.wrap("top")
- monit.setTextScale(0.5)
- x, y = monit.getSize()
- -- PassWord --
- PassWord="1994"
- PassWordTemp=""
- -- Matris Pad DE MERDE CAR LES ECRAN SONT MAL FOUTU --
- MatrisPad = {
- {"7","8","8",' ',"9"},
- {"4","5","5",' ',"6"},
- {' ',' ',' ',' ',' '},
- {"1","2","2",' ',"3"},
- {"1","2","2",' ',"3"},
- {' ',"0","0",' ',' '},
- {' ',"0","0",' ',' '}
- }
- -- Collection de Coord Pad --
- Coords_Pad = {
- ["0"] = { ["x"]=8,["y"]=10},
- ["1"] = { ["x"]=6,["y"]=8},
- ["2"] = { ["x"]=8,["y"]=8},
- ["3"] = { ["x"]=10,["y"]=8},
- ["4"] = { ["x"]=6,["y"]=6},
- ["5"] = { ["x"]=8,["y"]=6},
- ["6"] = { ["x"]=10,["y"]=6},
- ["7"] = { ["x"]=6,["y"]=4},
- ["8"] = { ["x"]=8,["y"]=4},
- ["9"] = { ["x"]=10,["y"]=4}
- }
- Coords_In = {
- {["x"]=5,["y"]=2},
- {["x"]=7,["y"]=2},
- {["x"]=9,["y"]=2},
- {["x"]=11,["y"]=2}
- }
- -- RAZ Monitor --
- function RAZ_Monitor(colorOver)
- PassWordTemp = ""
- if colorOver ~= nil then
- monit.setBackgroundColor(colorOver)
- else
- monit.setBackgroundColor(colors.lightGray)
- end
- monit.clear()
- end
- -- Error --
- function ErrorPass()
- for i=0,5 do
- RAZ_Monitor(colors.red)
- sleep(0.5)
- RAZ_Monitor()
- end
- Show_Pad()
- end
- -- Affiche le pad numerique --
- function Show_Pad()
- RAZ_Monitor()
- count = 9
- monit.setTextColor(colors.black)
- for i=3,9 do
- for j=11,5,-1 do
- if j%2 == 0 and i%2 == 0 then
- monit.setBackgroundColor(colors.lightGray)
- monit.setCursorPos(j,i)
- monit.write(""..count)
- count = count - 1
- else
- monit.setBackgroundColor(colors.white)
- monit.setCursorPos(j,i)
- monit.write(' ')
- end
- end
- end
- -- first ligne --
- monit.setCursorPos(5,2)
- for i=5,11 do
- if i%2 == 0 then
- monit.setBackgroundColor(colors.lightGray)
- else
- monit.setBackgroundColor(colors.black)
- end
- monit.write(' ')
- end
- -- last ligne --
- monit.setCursorPos(2,10)
- monit.setBackgroundColor(colors.red)
- monit.write(' c ')
- monit.setBackgroundColor(colors.white)
- monit.write(' ')
- monit.setBackgroundColor(colors.lightGray)
- monit.write('0')
- monit.setBackgroundColor(colors.white)
- monit.write(' ')
- monit.setCursorPos(12,10)
- monit.setBackgroundColor(colors.green)
- monit.write(' v ')
- monit.setBackgroundColor(colors.lightGray)
- end
- -- Input Sur le Clavier --
- function Saisie(num)
- if num ~= ' ' then
- -- Illumine la touche
- local coordT = Coords_Pad[num]
- monit.setBackgroundColor(colors.black)
- monit.setCursorPos(coordT["x"],coordT["y"])
- monit.write("0")
- sleep(0.05)
- monit.setBackgroundColor(colors.lightGray)
- monit.setCursorPos(coordT["x"],coordT["y"])
- monit.write(num)
- -- Add Pass
- if #PassWordTemp <4 then
- local coordI = Coords_In[#PassWordTemp+1]
- monit.setBackgroundColor(colors.black)
- monit.setCursorPos(coordI["x"],coordI["y"])
- monit.setTextColor(colors.white)
- monit.write("x")
- PassWordTemp = PassWordTemp..num
- end
- DefaultColor()
- end
- end
- -- Set Color --
- function DefaultColor()
- monit.setBackgroundColor(colors.lightGray)
- monit.setTextColor(colors.black)
- end
- -- Validation --
- function Validation()
- if PassWord == PassWordTemp then
- rs.setOutput("right",true)
- sleep(1)
- rs.setOutput("right",false)
- Show_Pad()
- else
- ErrorPass()
- end
- end
- -- init --
- Show_Pad()
- -- Boucle du program --
- while true do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- --monit.setCursorPos(1,1)
- --monit.write(xPos..' '..yPos..' ')
- -- Pad Numerique
- if (yPos<=10 and yPos >=5) and (xPos >=6 and xPos <= 11) then
- Saisie(MatrisPad[yPos-4][xPos-6])
- elseif yPos >=10 and (xPos >=3 and xPos <=5) then -- Cancel
- Show_Pad()
- elseif yPos >=10 and (xPos >=12 and xPos<=15) then -- Valider
- Validation()
- end
- end
Add Comment
Please, Sign In to add comment