File paths: I've tried everything

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.
User avatar
pgimeno
Party member
Posts: 2575
Joined: Sun Oct 18, 2015 2:58 pm

Re: File paths: I've tried everything

Post by pgimeno »

love.filesystem.getWorkingDirectory() tells you what the current directory is (what ./ is)-
togFox
Party member
Posts: 122
Joined: Sat Jan 30, 2021 9:46 am

Re: File paths: I've tried everything

Post by togFox »

On my machine:

D:/Program Files (x86)/Notepad++

(my love editor)

:(

Am I right in saying that

Code: Select all

sqlite3 = require("lsqlite3");
should simply look in the same folder as the exe? I mean - I'm not overthinking that am I?
User avatar
pgimeno
Party member
Posts: 2575
Joined: Sun Oct 18, 2015 2:58 pm

Re: File paths: I've tried everything

Post by pgimeno »

If that's what you want, maybe you can try this?

Code: Select all

package.cpath = love.filesystem.getSourceBaseDirectory() .. "/*.dll;" .. package.cpath
sqlite3 = require 'lsqlite3'
I don't know if love.filesystem.setCRequireDirectory() should be used instead. I haven't used binary packages. My guess is that it should be this one, as that's the real filesystem, as opposed to PhysFS's virtual filesystem.

Note also that love.filesystem.getSourceBaseDirectory() is broken. I need to use `love ./` instead of `love .` for it to return the correct directory.
User avatar
tomxp411
Prole
Posts: 7
Joined: Thu Apr 08, 2021 5:41 pm

Re: File paths: I've tried everything

Post by tomxp411 »

togFox wrote: Thu Apr 08, 2021 12:45 pm On my machine:

D:/Program Files (x86)/Notepad++

(my love editor)

:(

Am I right in saying that

Code: Select all

sqlite3 = require("lsqlite3");
should simply look in the same folder as the exe? I mean - I'm not overthinking that am I?
Unfortunately, that's not right. The "." in a path always means the "current working directory" (called the "default directory" in DOS/Windows.)

So your problem is that you're executing the game from a directory other than the game directory. IMO, LOVE really should CD into the game directory before starting, but that's not happening. So what you need to do is build a startup script that does it for you. Then run the game from the startup script.

On my development instances, I use a .cmd file to make that happen, which looks like this:

Code: Select all

%~d0
cd %~dp0
"C:\Program Files\LOVE\love.exe" %~dp0 --console
In Windows batch language, %0 is the full path to the batch file itself, and ~d and ~dp are prefixes that extract the drive and path from the parameter. So this script:
1. %~d0 Changes to the drive that the script sits in (very important, since CD doesn't do that for you)
2. cd %~dp0 Changes to the directory game lives in
3. "C:\Program Files\LOVE\love.exe" %~dp0 --console actually starts LOVE and passes it the game path. I use --console to pass debug information back while testing, but you can leave that out if you're not testing. (I have a separate "play.cmd" and "test.cmd" for that reason.)
Post Reply

Who is online

Users browsing this forum: Toad Venture and 14 guests