Hello.
Sorry if this question has been asked, but I've searched the forum and found nothing.
I just got started working in LOVE today. I am working on a testing application, and I needed a simple GUI interface. LOVE seemed to fit the bill. I would rather not share my .love file, as it has some confidential information already in it. However, I would be willing to make a "sanitized" version if whatever my problem is is not immediately apparent.
So anyway, I cannot open images. On my desktop, I have a folder for my program that contains the following files/folders:
autoTest.love
love.exe
DevIL.dll
OpenAL32.dll
SDL.dll
autoTest.bat (a batch file that contains this text: START love.exe autoTest.love)
AND the following folders:
Scripts
resources
Scripts contains various other Lua scripts I want to leave in Lua, not be zipped up.
The resources folder contains images for my GUI.
However, I cannot load any images at all. first, I tried using this script to load images:
scriptsInstalled = love.graphics.newImage('./resources/scripts_installed.jpg')
I get an error: "Could not open file ./resources/scripts_installed.jpg. Does not exist."
So I changed it to this:
scriptsInstalled = love.graphics.newImage(love.filesystem.getWorkingDirectory() .. '/resources/scripts_installed.jpg')
I get the same error, but now it gives me the full path on my C:\ drive.
So then I tried to just open the file
local f = love.filesystem.newFile(love.filesystem.getWorkingDirectory() .. '/resources/scripts_installed.jpg')
Same problem.
I even tried moving the image to the same directory as the .love file and love.exe. Same problem.
No matter what I do, I can't get it to open an image file. And yes, the file name is correct.
Can anyone help me with this limited description, or do I need to make a sanitized version of my LOVE application so that you guys can see the problem yourselves?
Why can't I open an image?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Why can't I open an image?
The love.filesystem wiki page states that it only gives access to two places. The game directory (either the directory with the main.lua or the contents of the Zip archive) and the save directory. Other places will not be accessible with the love.filesystem module. You cannot pass absolute paths to its functions. If it works for some functions, it's most likely because the underlying library (PhysicsFS) happens to allow it, but that's not by design.
Shallow indentations.
Re: Why can't I open an image?
Thank you very much! I read the filesystem documentation, but I misinterpreted what it meant by the two directories. I got it working now, by using this structure:
Base directory:
love files
autoTest -- folder
In in the "autoTest" folder
main.lua
Scripts -- folder
resources -- folder of images
Now, I can access my images like this:
scriptsInstalled = love.graphics.newImage('resources/scripts_installed.jpg')
Thanks once again!
IMO, it would be helpful if the file system library worked more like other file system libraries I've used...
Base directory:
love files
autoTest -- folder
In in the "autoTest" folder
main.lua
Scripts -- folder
resources -- folder of images
Now, I can access my images like this:
scriptsInstalled = love.graphics.newImage('resources/scripts_installed.jpg')
Thanks once again!
IMO, it would be helpful if the file system library worked more like other file system libraries I've used...
Re: Why can't I open an image?
The problem is portability and keeping it neat and clean over all (currently 3 supported) platforms. I'm sure the developers thought about it, but PhysicsFS is here for a bit longer for now.
Shallow indentations.
Re: Why can't I open an image?
Copy that, I figured they must have had a reason...Boolsheet wrote:The problem is portability and keeping it neat and clean over all (currently 3 supported) platforms. I'm sure the developers thought about it, but PhysicsFS is here for a bit longer for now.
Re: Why can't I open an image?
What happens if I try to include lfs?
http://keplerproject.github.com/luafilesystem/
Can I use it instead of the default file system? Or will there be issues?
http://keplerproject.github.com/luafilesystem/
Can I use it instead of the default file system? Or will there be issues?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Why can't I open an image?
There will be issues with those who use SELÖVE, a sandboxed version of LÖVE. For security reasons, a few things are disallowed (like running commands, e.g. "format C:\" or accessing random files on your computer, or loading C extensions (because in those extensions, anything goes)), and luafilesystem probably doesn't work without those things.
Otherwise, it will probably work for you.
Otherwise, it will probably work for you.
Help us help you: attach a .love.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest