MarcosKoco

LoginPassW

Jun 5th, 2021 (edited)
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.64 KB | None | 0 0
  1. local Version = "1.0.0"
  2. local ComputerVersion = "1.0.0"
  3.  
  4. local System = os -- Used for System things like os.time() to System.time()
  5. local Screen = term -- Used for Screen thing on the turtle or computer like term.clear() to Screen.clear()
  6. local Per = peripheral -- Used shortcut for peripheral
  7. local Text = textutils -- Used shortcut for textilils
  8. local Pack = Text.serialize -- Makes a new command for packing ( shortcut used from local Text)
  9. local UnPack = Text.unserialize -- Makes a new command for unpacking ( shortcut used from local Text)
  10.  
  11. local OldpullEvent = System.pullEvent
  12. System.pullEvent = System.pullEventRaw
  13.  
  14. local Computer = { ComputerName = "Computer",
  15.                 Status = true,
  16.                 LogOn = false
  17.                 }
  18.  
  19. local User = {  }
  20.  
  21. local Temp = {  }
  22.  
  23. function SaveTemp()
  24.    
  25.     Computer.UserName = User.UserName
  26.    
  27.     local Data = Pack(Computer)
  28.    
  29.     File = fs.open("OS/Temp/Temp.Tem", "w")
  30.     File.write(Data)
  31.     File.close()
  32.    
  33. end
  34.  
  35. local False = 0
  36.  
  37. function Loading()
  38.    
  39.     local File = fs.exists("OS/Users/."..User.UserName..".Acc")
  40.    
  41.     if not(File) then
  42.        
  43.         Screen.clear()
  44.        
  45.         local X, Y = Screen.getSize()
  46.         local Y2 = Y / 2
  47.        
  48.         Screen.setCursorPos(1, Y2)
  49.        
  50.         print(User.UserName.." dont exists!!!")
  51.        
  52.         sleep(3)
  53.         return false
  54.        
  55.     else
  56.        
  57.         File = fs.open("OS/Users/."..User.UserName..".Acc", "r")
  58.         Data = UnPack(File.readAll())
  59.         File.close()
  60.        
  61.         Temp.UserName = Data.UserName
  62.         Temp.Pass = Data.Pass
  63.        
  64.         if User.Pass == Temp.Pass then
  65.            
  66.             Screen.clear()
  67.            
  68.             local X, Y = Screen.getSize()
  69.             local Y2 = Y / 2
  70.            
  71.             Screen.setCursorPos(1, Y2)
  72.            
  73.             print("Password Accepted!!!")
  74.            
  75.             sleep(3)
  76.            
  77.             return true
  78.            
  79.         else
  80.            
  81.             Screen.clear()
  82.            
  83.             local X, Y = Screen.getSize()
  84.             local Y2 = Y / 2
  85.            
  86.             Screen.setCursorPos(1, Y2)
  87.            
  88.             print("Wrong Password!!!")
  89.            
  90.             False = False + 1
  91.            
  92.             sleep(3)
  93.            
  94.             if False == 3 then
  95.                
  96.                 os.reboot()
  97.                
  98.             end
  99.            
  100.             return false
  101.            
  102.         end
  103.        
  104.         Screen.clear()
  105.        
  106.         local X, Y = Screen.getSize()
  107.         local Y2 = Y / 2
  108.        
  109.         Screen.setCursorPos(1, Y2)
  110.        
  111.         print(User.UserName.." already exists!!!")
  112.        
  113.         sleep(3)
  114.         return false
  115.        
  116.     end
  117.    
  118. end
  119.  
  120. while not(Computer.LogOn) do
  121.    
  122.     Screen.clear()
  123.    
  124.     local X, Y = Screen.getSize()
  125.     local Temp = X / 2
  126.     local X2 = Temp - 2
  127.    
  128.     Screen.setCursorPos(X2, 1)
  129.    
  130.     print("Login :")
  131.    
  132.     Temp = Y / 2
  133.     local Y2 = Temp - 1
  134.    
  135.     Screen.setCursorPos(1, Y2)
  136.     write("UserName: ")
  137.     User.UserName = io.read()
  138.     Screen.setCursorPos(1, Y2+1)
  139.     write("Password: ")
  140.     User.Pass = read("*")
  141.    
  142.     Computer.LogOn = Loading()
  143.    
  144.     if Computer.LogOn then
  145.        
  146.         SaveTemp()
  147.        
  148.     end
  149.    
  150. end
Add Comment
Please, Sign In to add comment