Page 1 of 1

How to check for a file

Posted: Thu Dec 01, 2022 9:56 pm
by xcrvaz
Hey there! I'm new to love2d, and I would like to find out how to check if a file exists. I checked the wiki but it was a bit confusing.
[Slight information:
You need a password to play my game, and I made it so it adds a file that stores the password if its correct, how do I check if this file exists or not when entering the password. ]

Re: How to check for a file

Posted: Thu Dec 01, 2022 10:11 pm
by BrotSagtMist

Code: Select all

password=love.filesystem.read("file" )
if password then 
 rungame()
else 
 nopassword()
end
 

Re: How to check for a file

Posted: Thu Dec 01, 2022 10:40 pm
by xcrvaz
BrotSagtMist wrote: Thu Dec 01, 2022 10:11 pm

Code: Select all

password=love.filesystem.read("file" )
if password then 
 rungame()
else 
 nopassword()
end
 
Thanks!