How to Get file contents

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
xcrvaz
Prole
Posts: 7
Joined: Thu Nov 17, 2022 12:33 am

How to Get file contents

Post 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.
User avatar
BrotSagtMist
Party member
Posts: 657
Joined: Fri Aug 06, 2021 10:30 pm

Re: How to Get file contents

Post by BrotSagtMist »

Dude i just literally gave you the code in another thread.
obey
xcrvaz
Prole
Posts: 7
Joined: Thu Nov 17, 2022 12:33 am

Re: How to Get file contents

Post 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
User avatar
BrotSagtMist
Party member
Posts: 657
Joined: Fri Aug 06, 2021 10:30 pm

Re: How to Get file contents

Post by BrotSagtMist »

The function used is literally named read() what do you expect it does?
obey
User avatar
knorke
Party member
Posts: 274
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: How to Get file contents

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 5 guests