5 posts
                
             
            
                Posted 30 April 2012 - 09:18 PM
                I am making some software for a lockable door for my server, and i want it configurable. So i want the user to be able to put the password in a file called "pass", and then read the contents to a variable and compare to input from the person who wants to log in. How do i do that?
                
             
         
        
        
            
            
                
                    
                
                1111 posts
                
                    
                        Location
                        Portland OR
                    
                
             
            
                Posted 30 April 2012 - 09:48 PM
                Like this
local file = io.read("filename", "r") -- open file in read only
contents = file:read()
file:close()
while true do
write "Enter Password: "
local input = read("*")
if input == contents then
  print "correct password"
  doStuff()
  break
else
  print "invalid entry"
end
end
 
                
             
         
        
        
            
            
                
                    
                
                5 posts
                
             
            
                Posted 01 May 2012 - 03:48 PM
                <name> Expected at file:read()
                
             
         
        
        
            
            
                
                    
                
                8543 posts
                
             
            
                Posted 02 May 2012 - 03:30 AM
                Try changing the io.read call to an io.open call.  And make sure the file isn't blank.
                
             
         
        
        
            
            
                
                    
                
                1111 posts
                
                    
                        Location
                        Portland OR
                    
                
             
            
                Posted 02 May 2012 - 03:32 AM
                Try changing the io.read call to an io.open call.  And make sure the file isn't blank.
Ya my bad, it should be:
local file = io.open("filename", "r")