Page 2 of 2

Re: File paths: I've tried everything

Posted: Thu Apr 08, 2021 12:43 pm
by pgimeno
love.filesystem.getWorkingDirectory() tells you what the current directory is (what ./ is)-

Re: File paths: I've tried everything

Posted: Thu Apr 08, 2021 12:45 pm
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?

Re: File paths: I've tried everything

Posted: Thu Apr 08, 2021 1:26 pm
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.

Re: File paths: I've tried everything

Posted: Thu Apr 08, 2021 6:14 pm
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.)