I'm struggling to read a file under löve?
I know love.filesystem.open( file ) but that returns a boolean? so how can that boolean be the file? I'm confused by that.
Could someone provide an example of how to open a file and read it line by line? (The tutorials could do with one on reading files if I do say so myself)
Reading files under Löve
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Reading files under Löve
I believe it opens a buffer or some shit and the boolean is the success of it.
Once you have opened it you then need to manually read line by line or a given string length. Maybe you have come from an unprofessional shit thing like Garry's Mod where everything is handed to you on a plate with a knife, fork, and dessert. However, here you have almost direct access to the file system.
Once you have opened it you then need to manually read line by line or a given string length. Maybe you have come from an unprofessional shit thing like Garry's Mod where everything is handed to you on a plate with a knife, fork, and dessert. However, here you have almost direct access to the file system.
Re: Reading files under Löve
Psst:
love.filesystem.newFile( filename, mode )
it's not *just* for making new files. you can create a buffer to open your file in with this as well!
that said, booleans are not files. however, booleans can tell you if something is successful or not. newFile returns a file, which can be opened.
love.filesystem.newFile( filename, mode )
it's not *just* for making new files. you can create a buffer to open your file in with this as well!
that said, booleans are not files. however, booleans can tell you if something is successful or not. newFile returns a file, which can be opened.
Re: Reading files under Löve
I haven't come from Garry's Mod, but I do play Garry's Mod and I've never coded for it, Löve is the only LUA experience I have.Kudomiku wrote:I believe it opens a buffer or some shit and the boolean is the success of it.
Once you have opened it you then need to manually read line by line or a given string length. Maybe you have come from an unprofessional shit thing like Garry's Mod where everything is handed to you on a plate with a knife, fork, and dessert. However, here you have almost direct access to the file system.
If you really must know my background I started with TGE and I normally code with C++ & OpenGL but I had an idea and felt like making in with Löve.
I was reading the documentation and saw that, thought it would just be for creating files so I didn't have a look I'll take a gander at it.cag wrote:Psst:
love.filesystem.newFile( filename, mode )
it's not *just* for making new files. you can create a buffer to open your file in with this as well!
that said, booleans are not files. however, booleans can tell you if something is successful or not. newFile returns a file, which can be opened.
Re: Reading files under Löve
Related info:
In the next version, you'll be able to use love.filesystem without having to manage file handles.
In the next version, you'll be able to use love.filesystem without having to manage file handles.
Code: Select all
-- Read file contents directly
contents = love.filesystem.read("filename.txt")
-- Iterate over the lines in a file:
for line in love.filesystem.lines("filename.txt") do
...
end
Re: Reading files under Löve
Ahh, cool.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests