Advertisement
Guest User

ressources

a guest
Dec 28th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. ADMIN_PASS = "Mimidou00.."
  2. ADMIN_NAME = "BastouP"
  3. OWNER_NAME = {"TeKo"}
  4. USER_PASS = {["TeKo"] = "1596", ["Skylyx"] = "Sky04", ["xavcdb"] = "choucroute"}
  5.  
  6. function clr(arg)
  7.   term.clear()
  8.   if arg then
  9.     term.setCursorPos(1,1)
  10.   end
  11. end
  12.  
  13. function testPassword(test)
  14.   for k,v in pairs(USER_PASS) do
  15.     if test == v then
  16.       return k
  17.     end
  18.   end
  19.   return nil
  20. end
  21.  
  22. function testOwner(test)
  23.   for k,v in pairs(OWNER_NAME) do
  24.     if test == v then
  25.       return true
  26.     end
  27.   end
  28. end
  29.  
  30. function password(adm, admcol, txt)
  31.   clr(true)
  32.   if adm then
  33.     type = "owner"
  34.   else
  35.     type = "user"
  36.   end
  37.   print("+-------------------------------------------------+")
  38.   print("|["..txt.."] Enter "..type.." password please.")
  39.   print("|=>")
  40.   print("+-------------------------------------------------+")
  41.   print("|>")
  42.   print("+-------------------------------------------------+")
  43.   term.setCursorPos(51,2)
  44.   print("|")
  45.   term.setCursorPos(51,3)
  46.   print("|")
  47.   term.setCursorPos(51,5)
  48.   print("|")
  49.   term.setCursorPos(4,3)
  50.   pass = read("*")
  51.   user = testPassword(pass)
  52.   len = string.len(pass)
  53.   if adm then
  54.     if pass == ADMIN_PASS then
  55.       access = 2
  56.       phrase = "Welcome "..ADMIN_NAME.."!"
  57.       if admcol then
  58.         term.setTextColor(colors.cyan)
  59.       else
  60.         term.setTextColor(colors.lime)
  61.       end
  62.     elseif testOwner(user) then
  63.       access = 1
  64.       term.setTextColor(colors.lime)
  65.       phrase = "Welcome "..user.."!"
  66.     else
  67.       phrase = "Access denied."
  68.       access = 0
  69.       term.setTextColor(colors.red)
  70.     end
  71.   else
  72.     if pass == ADMIN_PASS then
  73.       access = 2
  74.       phrase = "Welcome "..ADMIN_NAME.."!"
  75.       if admcol then
  76.         term.setTextColor(colors.cyan)
  77.       else
  78.         term.setTextColor(colors.lime)
  79.       end
  80.     elseif user ~= nil then
  81.       access = 1
  82.       phrase = "Welcome "..user.."!"
  83.       term.setTextColor(colors.lime)
  84.     else
  85.       access = 0
  86.       phrase = "Access denied."
  87.       term.setTextColor(colors.red)
  88.     end
  89.   end
  90.   if len > 0 then
  91.   term.setCursorPos(4,3)
  92.     for i=1,len,1 do
  93.       write("*")
  94.     end
  95.   end
  96.   term.setCursorPos(4,5)
  97.   write(phrase)
  98.   term.setTextColor(colors.white)
  99.   return access
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement