 
                
                1 posts
                
             
            
                Posted 27 October 2016 - 08:42 PM
                So i made a simple door lock system but it seems not to be working? it gives me the
[string ".temp"]:13 '<eof>' expected error.
Take a look at this:
local x = "125690"
print(Enter password:  ")
pass = read()
if pass == x then
print("Correct password!")
rs.setOutput("right", true)
sleep(4)
os.shutdown()
end
else
write("Incorrect password!")
sleep(2)
os.shutdown()
end
                
             
         
        
        
            
            
                
                     
                
                7083 posts
                
                    
                        Location
                        Tasmania (AU)
                    
                
             
            
                Posted 28 October 2016 - 01:31 AM
                You can't "else" an "if" block you've already "end"ed.
                
             
         
        
        
            
            
                
                     
                
                1610 posts
                
             
            
                Posted 28 October 2016 - 03:14 AM
                Also, there's a missing quote in the print statement.
                
             
         
        
        
            
            
                
                     
                
                57 posts
                
             
            
                Posted 28 October 2016 - 08:26 AM
                You made the same mistakes I did lol :/
print("Door Lock")
write("Password: ")
password = read("*")
if password == "password123" then
print("Welcome Back")
sleep(1)
redstone.setOutput("right", true)
sleep(3)
os.shutdown()
else
print("Access Denied")
sleep(1)
term.clear()
print("Rebooting")
os.shutdown()
end
I wrote this a long time ago feel free to use this if you want :P/>
Edited on 28 October 2016 - 06:27 AM
                
             
         
        
        
            
            
                
                     
                
                172 posts
                
                    
                        Location
                        USA
                    
                
             
            
                Posted 29 October 2016 - 01:19 AM
                Here is the correct code:
local x = "125690"
print(Enter password: ")
pass = read()
if pass == x then
print("Correct password!")
rs.setOutput("right", true)
sleep(4)
os.shutdown()
else
write("Incorrect password!")
sleep(2)
os.shutdown()
end
 
         
        
        
            
            
                
                     
                
                756 posts
                
             
            
                Posted 29 October 2016 - 04:19 AM
                Here is the correct code, you should look up how to use 
while loops, instead of doing shutdown.
local x = "125690"
while true do
  term.clear()
  term.setCursorPos(1,1)
  term.write("Enter password: ")
  local pass = read("*")
  if pass == x then
	print("Correct")
	rs.setOutput("right", true)
	sleep(4)
	rs.setOutput("right", false)
  else
	print("Incorrect")
	sleep(1)
  end
end
Edited on 29 October 2016 - 02:20 AM