Page 1 of 3

How to load a file from game directory

Posted: Wed Sep 26, 2012 5:06 pm
by Factis
Hello guys. I made an map editor, and I have a problem.
The tileset have to be loaded from the "gfx/tiles" folder that is located in .exe file directory
But I can't load from game directory, only from .love archive!!!
Guys please help me.

How I can LOAD new IMAGE from game directory, not from .love archive?

Re: How to load a file from game directory

Posted: Wed Sep 26, 2012 5:24 pm
by Roland_Yonaba
Factis wrote:Hello guys. I made an map editor, and I have a problem.
The tileset have to be loaded from the "gfx/tiles" folder that is located in .exe file directory
But I can't load from game directory, only from .love archive!!!
Guys please help me.

How I can LOAD new IMAGE from game directory, not from .love archive?
I may be dumb, but I understood nothing.
Are you trying to access to some files located inside a *.love file ?
If so, why would you that ?

Basically, you just create an empty folder, which is supposed to be your project directory.
Inside, you create your main.lua, and conf.lua.Then you add all your games assets inside, or within subfolders,
still inside this project directory.
Then if you want to load anything, just keep in mind that the project directory is the root.
When you have finished, you zip the project directory contents (not the project directory itself), and rename its extension to .love.
That's basically how we all proceed.

So if I'm totally out of scope, accept my apologies, and restate the problem.

Re: How to load a file from game directory

Posted: Wed Sep 26, 2012 5:29 pm
by Factis
No, I want load image not from .love file but from the folder where .exe file will be located

Re: How to load a file from game directory

Posted: Wed Sep 26, 2012 5:57 pm
by Lafolie
love.filesystem

You can only access files from the save directory or the boot directory (the love file). That said, it's possible to use lua standard i/o stuff, but there is seLÖVE that disabled this behaviour, and for good reasons.

Re: How to load a file from game directory

Posted: Wed Sep 26, 2012 6:55 pm
by qaisjp
Please don't try things like that, putting resources outside the .exe doesn't make you look cool. If you are trying to test without having to repackage, you can simply drag the folder on top of the exe or create a .bat to open it for you.

Re: How to load a file from game directory

Posted: Wed Sep 26, 2012 10:51 pm
by josefnpat
Factis wrote:No, I want load image not from .love file but from the folder where .exe file will be located
Unless you include a Lua zip library to be able to add/remove/files from your .love, you're not going to have much fun.

What I would suggest is distributing your files like so:

Code: Select all

/start.bat --starts love.exe in the src folder.
/src/main.lua
/src/gamelibs.lua
/src/assets/img.png
/libs/love.exe
and distribute your game like that, instead of in .love form.
And then if love.filesystem doesn't do what you need, use the Lua's io to work around it.
qaisjp wrote:Please don't try things like that, putting resources outside the .exe doesn't make you look cool.
wat?

But seriously, I don't see whats wrong with distributing non .love files as long as you've exhausted the alternatives.

Re: How to load a file from game directory

Posted: Thu Sep 27, 2012 4:14 pm
by qaisjp
I mean, some studios bla de bla have most of their resources outside of the .exe, so I was telling the OP not to try and be like them and keep them in a directory where the .exe lies.

Re: How to load a file from game directory

Posted: Thu Sep 27, 2012 6:01 pm
by josefnpat
qaisjp wrote:I mean, some studios bla de bla have most of their resources outside of the .exe, so I was telling the OP not to try and be like them and keep them in a directory where the .exe lies.
If you install 100 AAA titles, 99% of them will have resources outside of the .exe file. I think as long as you understand the complications, it's a perfectly reasonable way to distribute a game.

I'll say it again;

I don't see whats wrong with distributing non .love files as long as you've exhausted the alternatives.

Re: How to load a file from game directory

Posted: Fri Sep 28, 2012 10:53 am
by Robin
josefnpat wrote:If you install 100 AAA titles, 99% of them will have resources outside of the .exe file.
I think that was his point: just because AAA titles (which is a ridiculous name, by the way) do it, doesn't mean you have to do it. If you do something like that, do it for the right reasons, not just because you think it makes you seem cool or "professional".

Also, I don't care how you distribute your games, but every time you use Lua's IO library in a LÖVE project, god kills a kitten.

Re: How to load a file from game directory

Posted: Fri Sep 28, 2012 11:45 am
by Roland_Yonaba
Robin wrote:every time you use Lua's IO library in a LÖVE project, god kills a kitten.
Gee. Wondering how many kitten should've died from that...