Advertisement
Guest User

ressources

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