Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- margin = 1
- mon = peripheral.wrap("right")
- mon.setTextScale(1)
- shift = true
- cur = false
- mon.clear()
- password = "Pass!"
- on = true
- xx = 1
- yy = 7
- keys = {
- {"1","2","3","4","5","6","7","8","9","0","-","="," "," "},
- {"q","w","e","r","t","y","u","i","o","p","[","]"," ","S"},
- {"a","s","d","f","g","h","j","k","l",";","'"," "," ","X"},
- {"z","x","c","v","b","n","m",",",".","/"," ","<",">","_"}
- }
- keysShift = {
- {"!","@","#","$","%","^","&","*","(",")","_","+"," "," "},
- {"Q","W","E","R","T","Y","U","I","O","P","{","}","|","s"},
- {"A","S","D","F","G","H","J","K","L",":"," "," "," ","x"},
- {"Z","X","C","V","B","N","M"," "," ","?"," ","<",">","_"}
- }
- temppass = ""
- function prints(offx,offy,tabl)
- -- print("print function called")
- for i = 1,#tabl do
- for j = 1,#tabl[i] do
- mon.setCursorPos(offy+j,offx+i)
- mon.write(tabl[i][j])
- mon.setCursorPos(xx,yy)
- end
- end
- end
- function win()
- on = false
- printreadout(6,8,"Pass")
- end
- function lose()
- on = false
- printreadout(6,8,"Fail")
- end
- function pass(str)
- if str == password then
- win()
- else
- lose()
- end
- end
- function printreadout(x,y,str)
- mon.setCursorPos(x,y)
- mon.write(str)
- xx = #str+1
- yy = y
- end
- function printtable(table)
- for i = 1,#table do
- print(table[i])
- end
- end
- function detect(offx,offy,tabl)
- event,side,x,y = os.pullEvent("monitor_touch")
- x = x - offx
- y = y - offy
- height = #tabl+offy
- width = #tabl[1]+offx
- --[[
- print(x)
- print(y)
- print(offx)
- print(offy)
- print(x-offx)
- print(y-offy)
- ]]--
- if x > 0 and y < height and y > 0 and x < width then
- letter = tabl[y][x]
- if letter == ">" then
- pass(temppass)
- elseif letter == "X" and shift == false or letter == "x" and shift == true then
- --clear enter (clear the table 'temppass')
- printreadout(margin,height+2," ")
- temppass = ""
- elseif letter == "_" then
- temppass = temppass.." "
- elseif letter == "<" then
- temppass = temppass:sub(0,#temppass-1)
- printreadout(margin,height+2," ")
- printreadout(margin,height+2,temppass)
- elseif letter == " " then
- elseif letter == "S" and shift == false or letter == "s" and shift == true then
- cur = not cur
- else
- temppass = temppass..letter
- end
- end
- end
- height = #keys
- mon.setCursorPos(margin,height+2)
- mon.setCursorBlink(true)
- while on do
- if shift == true and cur == false then
- shift = false
- prints(margin,2,keys)
- elseif shift == false and cur == true then
- shift = true
- prints(margin,2,keysShift)
- end
- if shift == false then
- detect(2,margin,keys)
- elseif shift == true then
- detect(2,margin,keysShift)
- end
- printreadout(margin,height+2,temppass)
- end
- mon.setCursorBlink(false)
Advertisement
Add Comment
Please, Sign In to add comment