Accessing LOVE archive files

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Palmar
Prole
Posts: 23
Joined: Thu Dec 13, 2012 3:54 pm

Accessing LOVE archive files

Post 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.
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Accessing LOVE archive files

Post 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.
Palmar
Prole
Posts: 23
Joined: Thu Dec 13, 2012 3:54 pm

Re: Accessing LOVE archive files

Post by Palmar »

But it loads LUA's file function, and I need just a single txt file.
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Accessing LOVE archive files

Post by Azhukar »

Palmar
Prole
Posts: 23
Joined: Thu Dec 13, 2012 3:54 pm

Re: Accessing LOVE archive files

Post 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:
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Accessing LOVE archive files

Post 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:
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
slime
Solid Snayke
Posts: 3160
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Accessing LOVE archive files

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

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests