Hello.
I use the first day Love2D, but the engine already very much is pleasant to me. I carried out all evening behind documentation, but didn't find the answer to the question. So, I want to use the external folder for storage of graphics and sounds. That is, at me is game.exe and the data folder where there are game images.
I tried to write such code:
function love.load ()
dirwork = love.filesystem.getWorkingDirectory ()
hamster = love.graphics.newImage (dirwork. "/data/hamster.png")
end
But to me write that: Could not open file D:/Game/data/hamster.png. Does not exist.
Whether can load Love2D the graphic file from the outside or I should push everything in game.exe?
Could not open external file. Does not exist.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Could not open external file. Does not exist.
The love.filesystem page has information on this. It does not take absolute paths and it can only read from the save directory and the game directory/archive. Yes, the idea is that you pack everything into the archive. If you really have to go outside of these directories, you have to use the Lua IO library (not recommended because of portability issues) or some Lua module that provides file system access.
Also note that the working directory can point anywhere on the file system. This does not have to be the path of the executable.
Also note that the working directory can point anywhere on the file system. This does not have to be the path of the executable.
Shallow indentations.
Re: Could not open external file. Does not exist.
Once you convert the game to a .exe all the image files and such should be inside the .exe (you first make a .love file; a zipped folder with everything in it except .dll and such and then merge that into the love.exe)
But during development, you can keep them stored outside as long as they are in the same folder, and you won't need to add the getWorkingDirectory() part when including files. You can just include "love.graphics.newImage( "path/hamster.png" )
But during development, you can keep them stored outside as long as they are in the same folder, and you won't need to add the getWorkingDirectory() part when including files. You can just include "love.graphics.newImage( "path/hamster.png" )
Re: Could not open external file. Does not exist.
I would like to give the user the ability to modify the game without opening its source. Actually, that interests me OPEN game resources.
If there is any way to load an image from the outside - can I get it? You said something about Lua IO - even if I can use it if I can upload an image in Love? Or is there any other solutions? Besides LoveFS - annoying flash terminals at startup.
If there is any way to load an image from the outside - can I get it? You said something about Lua IO - even if I can use it if I can upload an image in Love? Or is there any other solutions? Besides LoveFS - annoying flash terminals at startup.
Re: Could not open external file. Does not exist.
If you want to allow modding, the best solution might be to simply not pack everything into a .exe file, but instead leave everything unpacked. You can change the arguments passed to love.exe when it runs so that it opens the game when you doubleclick it and then rename the file to the name of your game. That way all the files are available for users to edit, including pictures and such.
Re: Could not open external file. Does not exist.
You could also write your resources to the save directory and let the users modify that. Like the love.filesystem page says, it has precedence over the game directory and it will load the things from there if the file names match. Sadly, the different operating systems make it a bit tricky for the average user to get to the application data specific directories (they mark them as hidden).
If you use the Lua IO (or another module) you would have to go over FileData to get an Image or one of the other things out of it.
If you use the Lua IO (or another module) you would have to go over FileData to get an Image or one of the other things out of it.
I was thinking LuaFileSystem instead of a massive abuse of os.execute and io.popen. Then again, loading binary modules with the official LÖVE 0.8.0 Windows binary is a bit cumbersome because it linked Lua statically. Just placing a different Lua DLL into the executable directory works, but is really not a clean approach.AleVerDes wrote:Or is there any other solutions? Besides LoveFS - annoying flash terminals at startup.
Shallow indentations.
Re: Could not open external file. Does not exist.
Boolsheet wrote:You could also write your resources to the save directory and let the users modify that. Like the love.filesystem page says, it has precedence over the game directory and it will load the things from there if the file names match. Sadly, the different operating systems make it a bit tricky for the average user to get to the application data specific directories (they mark them as hidden).
This. Then all you have to do is to help your users find the files. Alternatively, you can create the files from within LÖVE and save them with love.filesystem.
My game has a level editor that allows you to create and modify levels. The levels you make or modify are placed in the love.filesystem directory and will automatically be loaded instead of the built in levels.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
-
- Prole
- Posts: 2
- Joined: Sun Jun 09, 2013 10:54 pm
Re: Could not open external file. Does not exist.
Is there any possibility that this restriction might be removed in the future? It seems quite obnoxious to not be able to have a resources or data folder inside your project folder, as I would really like to be able to use a file structure for organization, especially when projects get large. Having everything just lumped in one folder seems like it has a lot of potential for really tough problems later on in projects, especially mine, where I will have lots and lots of images used for animations.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Could not open external file. Does not exist.
You do know you can have subdirectories.. right?
-
- Prole
- Posts: 2
- Joined: Sun Jun 09, 2013 10:54 pm
Re: Could not open external file. Does not exist.
Ah yes, I do. I was having what turned out to be an unrelated problem, which I have now fixed. I feel dumb.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests