Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- --Monitor/Sensor
- monSide = "back"
- senSide = "top"
- --Tastenfeld
- Bcolor = colors.gray
- Tcolor = colors.lightGray
- --Hintergrund
- Bcol = colors.black
- --RS-Seiten
- tuer = "bottom"
- falsch = "left"
- mon = peripheral.wrap(monSide)
- proximity = sensor.wrap(senSide)
- xMax,yMax = mon.getSize()
- --background
- function bdraw()
- for yPos = 1,yMax do
- for xPos = 1,xMax do
- mon.setCursorPos(xPos,yPos)
- mon.setBackgroundColor(Bcol)
- mon.write(" ")
- end
- end
- end
- --layout
- function layout()
- mon.setBackgroundColor(Bcolor)
- mon.setTextColor(Tcolor)
- mon.setCursorPos(2,1)
- mon.write("1")
- mon.setCursorPos(4,1)
- mon.write("2")
- mon.setCursorPos(6,1)
- mon.write("3")
- mon.setCursorPos(2,3)
- mon.write("4")
- mon.setCursorPos(4,3)
- mon.write("5")
- mon.setCursorPos(6,3)
- mon.write("6")
- mon.setCursorPos(2,5)
- mon.write("7")
- mon.setCursorPos(4,5)
- mon.write("8")
- mon.setCursorPos(6,5)
- mon.write("9")
- mon.setCursorPos(8,1)
- mon.setBackgroundColor(colors.cyan)
- mon.write("R ")
- mon.setCursorPos(8,3)
- mon.setBackgroundColor(colors.red)
- mon.write("C ")
- mon.setCursorPos(8,5)
- mon.setBackgroundColor(colors.green)
- mon.write("OK")
- end
- --
- i=1
- --main program
- bdraw()
- layout()
- rs.setOutput(tuer, false)
- rs.setOutput(falsch, false)
- while true do
- stelle = 0
- password = nil
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(10,1)
- mon.write(" ")
- --Spieler erkennung
- targets = proximity.getTargets()
- for k,v in pairs(targets) do
- if v.Name == "Player"
- and v.Position.X <= 1 and v.Position.X >= -1
- and v.Position.Y <= 0 and v.Position.Y >= -4
- and v.Position.Z <= 4 and v.Position.Z >= 1.5 then
- player = k
- mon.setBackgroundColor(Bcolor)
- mon.setCursorPos(10,1)
- mon.write(player)
- file = fs.open("pw", "r")
- line = file.readLine()
- count = 1
- while line ~= nil do
- pl = line
- line = file.readLine()
- pw = line
- line = file.readLine()
- count = count + 1
- if player == pl then
- password = pw
- end
- end
- if password == nil then
- print("Spieler nicht erkannt")
- rs.setOutput(falsch, true)
- sleep(3)
- rs.setOutput(falsch, false)
- end
- file.close()
- eingabe = true
- Kennwort = {}
- while eingabe do
- event,_,xPos,yPos = os.pullEvent("monitor_touch")
- b = nil
- if xPos == 2 and yPos == 1 then
- print("1")
- b = 1
- elseif xPos == 4 and yPos == 1 then
- print("2")
- b = 2
- elseif xPos == 6 and yPos == 1 then
- print("3")
- b = 3
- elseif xPos == 2 and yPos == 3 then
- print("4")
- b = 4
- elseif xPos == 4 and yPos == 3 then
- print("5")
- b = 5
- elseif xPos == 6 and yPos == 3 then
- print("6")
- b = 6
- elseif xPos == 2 and yPos == 5 then
- print("7")
- b = 7
- elseif xPos == 4 and yPos == 5 then
- print("8")
- b = 8
- elseif xPos == 6 and yPos == 5 then
- print("9")
- b = 9
- elseif xPos >= 8 and xPos <=9 and yPos == 1 then
- print("R")
- os.reboot()
- elseif xPos >= 8 and xPos <=9 and yPos == 3 then
- print("C")
- b = -1
- stelle = stelle-2
- elseif xPos >= 8 and xPos <=9 and yPos == 5 then
- print("OK")
- b = 0
- end
- if b ~= nil then
- stelle = stelle+1
- end
- if stelle == -1 then
- stelle = 0
- end
- if stelle > 4 then
- stelle = 4
- end
- if b==0 then
- for g = 1,4 do
- if Kennwort[g] == nil then
- bdraw()
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.red)
- mon.write("mindestens 4")
- mon.setCursorPos(1,2)
- mon.write("Zahlen eingeben!")
- sleep(3)
- os.reboot()
- end
- end
- Kwkomplett = Kennwort[1] .. Kennwort[2] .. Kennwort[3] .. Kennwort[4]
- if Kwkomplett == password then
- bdraw()
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.green)
- mon.write("Passwort")
- mon.setCursorPos(1,2)
- mon.write("akzeptiert")
- rs.setOutput(tuer, true)
- sleep(5)
- rs.setOutput(tuer, false)
- os.reboot()
- else
- bdraw()
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.red)
- mon.write("Falsches Passwort")
- rs.setOutput(falsch, true)
- sleep(3)
- rs.setOutput(falsch, false)
- os.reboot()
- end
- elseif b==-1 then
- if stelle > 0 then
- Kennwort[stelle+1] = nil
- end
- else
- Kennwort[stelle] = b
- end
- mon.setCursorPos(10,3)
- mon.setBackgroundColor(Bcol)
- mon.write(" ")
- for stern = 1,stelle do
- mon.setCursorPos(10+stern,3)
- mon.setBackgroundColor(Bcolor)
- mon.write("*")
- end
- end
- end
- end
- mon.setBackgroundColor(Bcol)
- mon.setTextColor(Tcolor)
- if i == 1 then
- mon.setCursorPos(11,1)
- mon.write("Ooo")
- elseif i == 2 then
- mon.setCursorPos(11,1)
- mon.write("oOo")
- elseif i == 3 then
- mon.setCursorPos(11,1)
- mon.write("ooO")
- elseif i == 4 then
- mon.setCursorPos(11,1)
- mon.write("ooo")
- i=0
- end
- i=i+1
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment