How do I make LOVE's filesystem prioritize searching the game directory?

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
User avatar
DTmg
Prole
Posts: 6
Joined: Tue Apr 18, 2023 12:47 pm
Contact:

How do I make LOVE's filesystem prioritize searching the game directory?

Post by DTmg »

I noticed some odd behavior when messing around with loading resources like images: LOVE 11.4's filesystem seems to prioritize searching for resources in the save directory over the actual loaded game's directory. What I mean by this, is when I go to read a file using any of the functions that follow LOVE's filesystem, if there is a file by the same name present in both directories the game chooses the one in the save directory. This wouldn't be so much of a problem for me if the require function didn't follow this same behavior, but when loading files using it the game also chooses the save directory over the game directory. This is the case regardless of if the game is packaged in a .love or not. Is there a way to change this to make LOVE prioritize searching the game directory over the save directory? I have searched through the wiki and looked for similar forum posts and didn't find anything.

Code: Select all

function explode()
    return explode()
end

explode()
User avatar
slime
Solid Snayke
Posts: 3133
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: How do I make LOVE's filesystem prioritize searching the game directory?

Post by slime »

This is a feature to enable easier modding and saved-settings-with-defaults support. You can change that behaviour with t.appendidentity = true in love.conf, or with love.filesystem.setIdentity.

That said, if you don't want game directory and save directory files to overlap at all you can just use different subfolder or file names for things in the game directory versus the save directory.
User avatar
DTmg
Prole
Posts: 6
Joined: Tue Apr 18, 2023 12:47 pm
Contact:

Re: How do I make LOVE's filesystem prioritize searching the game directory?

Post by DTmg »

Ah ok, I completely missed that. Thank you, that solved the issue and I'm still able to access saved data when I need to!

Code: Select all

function explode()
    return explode()
end

explode()
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 65 guests