Page 1 of 1

How to Get file contents

Posted: Thu Dec 01, 2022 11:01 pm
by xcrvaz
Hey, I'm brand new to love2d. How do you get the contents of a file?
[[ Context: I'm making a game where you need a password to play. The password gets saved if it's Correct. How do I read the password back to the game so users dont have to re-enter the password. ]]
P.S: I Checked the forums, and it said something about returns, and I honestly have no idea how to use return. I've been using lua for about 2 years and I got no idea how to use returns.

Re: How to Get file contents

Posted: Thu Dec 01, 2022 11:03 pm
by BrotSagtMist
Dude i just literally gave you the code in another thread.

Re: How to Get file contents

Posted: Thu Dec 01, 2022 11:04 pm
by xcrvaz
BrotSagtMist wrote: Thu Dec 01, 2022 11:03 pm Dude i just literally gave you the code in another thread.
Not to read, to check if the file exists.. This is to read

Re: How to Get file contents

Posted: Thu Dec 01, 2022 11:09 pm
by BrotSagtMist
The function used is literally named read() what do you expect it does?

Re: How to Get file contents

Posted: Thu Dec 01, 2022 11:26 pm
by knorke
xcrvaz wrote: Thu Dec 01, 2022 11:01 pm P.S: I Checked the forums, and it said something about returns, and I honestly have no idea how to use return. I've been using lua for about 2 years and I got no idea how to use returns.
Hi
I suggest to get familiar with basic concepts of Lua and Löve.
Otherwise you will constantly run into obstacles or do things in very weird and cumbersome ways.
For example using a function that reads a file can be super confusing if you do not yet know how functions work in general.
On the wiki is a list of tutorials, both texts and videos:
https://love2d.org/wiki/Category:Tutorials
This one seems good: https://sheepolution.com/learn/book/contents
In chapter 3 it explains functions and functions with return values.