How to load a file from game directory

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Factis
Prole
Posts: 14
Joined: Sun Sep 23, 2012 5:38 pm

How to load a file from game directory

Post 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?
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: How to load a file from game directory

Post 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.
Factis
Prole
Posts: 14
Joined: Sun Sep 23, 2012 5:38 pm

Re: How to load a file from game directory

Post by Factis »

No, I want load image not from .love file but from the folder where .exe file will be located
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: How to load a file from game directory

Post 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.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: How to load a file from game directory

Post 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.
Lua is not an acronym.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: How to load a file from game directory

Post 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.
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: How to load a file from game directory

Post 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.
Lua is not an acronym.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: How to load a file from game directory

Post 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.
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How to load a file from game directory

Post 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.
Help us help you: attach a .love.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: How to load a file from game directory

Post 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...
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests