wv1106

password

Feb 19th, 2022 (edited)
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. local password = "wasdf"
  2. local enterd = ""
  3.  
  4.  
  5. function creGUI()
  6.     term.setBackgroundColor(colors.blue)
  7.     term.clear()
  8.     term.setCursorPos(4, 7)
  9.     term.write("enter password")
  10.     for i=0,#password do
  11.         term.setCursorPos(i*4, 9)
  12.         if i<=#enterd then
  13.             term.write("*")
  14.         else
  15.             term.write("_")
  16.         end
  17.     end
  18. end
  19.  
  20. while 1 do
  21.     creGUI()
  22.     local event = {os.pullEventRaw()}
  23.     if event[1]=="key" then
  24.         enterd = enterd..keys.getName(event[2])
  25.     end
  26.     if password==enterd then
  27.         term.setBackgroundColor(colors.black)
  28.         term.clear()
  29.         term.setCursorPos(1, 1)
  30.         sleep(0.5)
  31.         break
  32.     end
  33.     if #password <= #enterd then
  34.         enterd = ""
  35.     end
  36. end
Add Comment
Please, Sign In to add comment