Page 1 of 1

Set CWD to game folder on startup

Posted: Sat Jul 05, 2014 1:30 am
by Someguynamedpie
Unless I'm doing something wrong, the CWD seems to be set to the folder LOVE is in. After all the libraries necessary in Love are initiated, it'd make sense to set the CWD to the game folder

Re: Set CWD to game folder on startup

Posted: Sat Jul 05, 2014 4:38 am
by slime
The current working directory is the current directory of the shell the user launched LÖVE from, if they're using a terminal. If not, it depends on the OS - in Mac OS X, the working directory is always "/" (the root) when LÖVE is launched as a regular application.

However that's all irrelevant for anyone writing code for LÖVE, because [wiki]love.filesystem[/wiki] is what you will use, and it doesn't use the system's current working directory. You shouldn't use io.open or loadfile in a LÖVE game - use love.filesystem.read (or [wiki]love.filesystem.newFile[/wiki]) and require or love.filesystem.load instead.