As I was programming, I attempted to load in text files from a folder inside of my source. Upon testing, it seems to be looking for files in the folder where I ran the game, not where the main source files are.
The first printed path is my working directory, where it's looking for files. This should be set to my directory where I have my main.lua/conf.lua (my source folder), but is instead set to the directory where I've ran the love file. "res/dat/test.txt" is located inside of my game's source folder, which is where I would like to require files from.
Hopefully I didn't explain it too terribly, as I won't have access to the .love file for a while. If anyone could point me in the right direction, that would be great!
Edit: On further inspection, the source folder seems to be set to whatever directory I run my game from. Is there a way to only look for files inside the source directory?
Source path seems to be off..
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Source path seems to be off..
How did you run LÖVE? And could you upload a .love that shows this problem for you?
Help us help you: attach a .love.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Source path seems to be off..
That is because that is the working directory. If you're using love.filesystem, though, that shouldn't be a problem, since it doesn't care about the working directory.
Re: Source path seems to be off..
I was simply trying to load in a text file from a path using dofile(). The same error occurs when I try to load in an image from a path as well, as it's trying to look in my love directory for a res folder when the res folder is actually inside of my .love file.bartbes wrote:That is because that is the working directory. If you're using love.filesystem, though, that shouldn't be a problem, since it doesn't care about the working directory.
I'll be able to upload a .love file when I get home from work, but I ran it by simply dragging a properly structured .love file onto love.exe. The same error occurs when I drag the folder on top of love.exe as well.Robin wrote:How did you run LÖVE? And could you upload a .love that shows this problem for you?
Re: Source path seems to be off..
Finally was able to upload a .love file. Beware, super non-commented moonscript generated code ahead. This was made to be a test of a quick framework I'm making for myself for jam games, so that's why there's a ton of stuff in the lib folder that's not being used.
What you should probably be looking at is the reg.lua file, which has the paths that I concatenate along with the file names, as well as the loadLevel function that is throwing the error. You should be able to see the directories I'm trying to locate as well.
What you should probably be looking at is the reg.lua file, which has the paths that I concatenate along with the file names, as well as the loadLevel function that is throwing the error. You should be able to see the directories I'm trying to locate as well.
- Attachments
-
- frameworktest.love
- (5.83 MiB) Downloaded 137 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Source path seems to be off..
reg.lua, line 13. Try replacing dofile(fn) with [wiki]love.filesystem.load[/wiki](fn)().
Fun fact: the love filesystem only affects require, not dofile or the io.* functions. (This is because require is extensible, while dofile etc. aren't, and LÖVE never overwrites the standard library)
Fun fact: the love filesystem only affects require, not dofile or the io.* functions. (This is because require is extensible, while dofile etc. aren't, and LÖVE never overwrites the standard library)
Help us help you: attach a .love.
Re: Source path seems to be off..
Thanks, this worked! Need to get this thing in working order for a local jam on Saturday, and that was stumping me. I'll be sure to use love.filesystem for these situations in the future.Robin wrote:reg.lua, line 13. Try replacing dofile(fn) with [wiki]love.filesystem.load[/wiki](fn)().
Fun fact: the love filesystem only affects require, not dofile or the io.* functions. (This is because require is extensible, while dofile etc. aren't, and LÖVE never overwrites the standard library)
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests