Page 1 of 1

Accessing LOVE archive files

Posted: Fri Mar 07, 2014 9:55 am
by Palmar
Sorry if there was thread like this, but I found nothing on keywords "archive", "accessing LOVE archive" and etc.
I have "levels" directory in my LOVE archive, where I store my game levels. I need to read those files. I know how to read and write files in %APPDATA% directory, but is there any way to open files stored in .LOVE archive? Is this related to love.filesystem.mount?
Thanks in advance, and sorry for my bad english.

Re: Accessing LOVE archive files

Posted: Fri Mar 07, 2014 10:35 am
by Plu
You should just be able to use love.filesystem.load:
https://love2d.org/wiki/love.filesystem.load

It will check the save directory for the file and then if it cannot find it, it will also check the root directory of your archive.

EDIT: if you're already using this function and it stopped working when you made an archive, make sure you check capitalisation. Windows isn't case sensitive, and will gladly open "someFile.dat" if you say love.filesystem.load( "somefile.dat" ), but the archive is case sensitive and will stumble over the missing capital F.

Re: Accessing LOVE archive files

Posted: Fri Mar 07, 2014 10:37 am
by Palmar
But it loads LUA's file function, and I need just a single txt file.

Re: Accessing LOVE archive files

Posted: Fri Mar 07, 2014 11:26 am
by Azhukar

Re: Accessing LOVE archive files

Posted: Fri Mar 07, 2014 1:47 pm
by Palmar
Already done. Problem solved. There is no information on wiki that LOVE reads first in archive, and only then in %APPDATA%, huh. :halloween:

Re: Accessing LOVE archive files

Posted: Sat Mar 08, 2014 4:46 am
by Positive07
Palmar wrote:There is no information on wiki that LOVE reads first in archive, and only then in %APPDATA%, huh. :halloween:
Really? I went to the love.filesystem page on the wiki and the first lines says:
Provides an interface to the user's filesystem.

This module provides access to files in two places, and two places only:

The root folder of the .love archive (or source directory)
The root folder of the game's save directory.
:o

Later on it says:
Files that are opened for read will be looked for in the save directory, and then in the .love archive (in that order). So if a file with a certain filename (and path) exist in both the .love archive and the save folder, the one in the save directory takes precedence.
... Pretty clear right? :huh:

Re: Accessing LOVE archive files

Posted: Sat Mar 08, 2014 5:09 am
by slime
You can change the behaviour with the optional second argument to [wiki]love.filesystem.setIdentity[/wiki], or by adding t.appendidentity = true to your love.conf function if you don't call love.filesystem.setIdentity.