Advertisement
Guest User

startup

a guest
Nov 23rd, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. old=os.pullEvent
  2. os.pullEvent=os.pullEventRaw
  3. os.loadAPI("walCrypt")
  4. function invalid(txt,st,col)
  5.   term.setCursorPos(1,1)
  6.   term.setTextColor(col)
  7.   term.setBackgroundColor(colors.blue)
  8.   sX,sY=term.getSize()
  9.   for u=1,sX do
  10.     write(" ")
  11.   end
  12.   term.setCursorPos(st,1)
  13.   write(txt)
  14.   sleep(3)
  15.   term.setTextColor(colors.black)
  16. end
  17. function main()
  18.   d=true
  19.   while d do
  20.     term.setBackgroundColor(colors.lightGray)
  21.     term.clear()
  22.     term.setCursorPos(1,1)
  23.     term.setBackgroundColor(colors.blue)
  24.     sX,sY=term.getSize()
  25.     for i=1,sX*2 do
  26.       write(" ")
  27.     end
  28.     term.setCursorPos(19,1)
  29.     term.setTextColor(colors.black)
  30.     print("Please login: ")
  31.     term.setBackgroundColor(colors.lightGray)
  32.     term.setCursorPos(15,9)
  33.     term.setTextColor(colors.blue)
  34.     write("Username: ")
  35.     term.setBackgroundColor(colors.gray)
  36.     write("               ")
  37.     term.setCursorPos(15,11)
  38.     term.setTextColor(colors.blue)
  39.     term.setBackgroundColor(colors.lightGray)
  40.     write("Password: ")
  41.     term.setBackgroundColor(colors.gray)
  42.     write("               ")
  43.     term.setCursorPos(26,9)
  44.     term.setTextColor(colors.cyan)
  45.     inUser = read()
  46.     term.setCursorPos(26,11)
  47.     inPass = read("*")
  48.     if fs.exists("loginSettings/users/"..inUser) then
  49.       a = fs.open("loginSettings/users/"..inUser,"r")
  50.       pass = a.readLine()
  51.       a.close()
  52.       if tonumber(pass) == walCrypt.walCrypter(inPass) then
  53.         d=false
  54.       else
  55.         invalid("Invalid login",19,colors.red)
  56.       end
  57.     else
  58.       invalid("Invalid login",19,colors.red)
  59.     end
  60.   end
  61.   invalid("Valid login",20,colors.green)
  62.   os.pullEvent = old
  63.   term.setBackgroundColor(colors.black)
  64.   term.setTextColor(colors.white)
  65.   term.clear()
  66.   term.setCursorPos(1,1)
  67.   curUser=inUser
  68.   us=fs.open("loginSettings/curUser","w")
  69.   us.writeLine(curUser)
  70.   us.flush()
  71.   us.close()
  72.   shell.run(".shell")    
  73. end
  74. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement