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.
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

Re: How to load a file from game directory

Post by OmarShehata »

Robin wrote: 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.
I don't see what's so wrong about that. Wouldn't a game with C++ have the same access to your files? So if you trust to run an exe then that shouldn't be a problem. (Unless you mean when distributing your game as a .love)

Also, keeping assets out of the exe can be useful especially if you want people to mod your game. Or update/edit graphics and other files without recompiling anything.
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 »

OmarShehata wrote:(Unless you mean when distributing your game as a .love)
Yeah, this basically is about LAAP vs LAAF (LÖVE As A Platform/Framework). I might be a bit biased. :P
OmarShehata wrote:Also, keeping assets out of the exe can be useful especially if you want people to mod your game. Or update/edit graphics and other files without recompiling anything.
We have the save directory for that. :)
Help us help you: attach a .love.
User avatar
slime
Solid Snayke
Posts: 3160
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: How to load a file from game directory

Post by slime »

Robin wrote: We have the save directory for that. :)
The save directory is an extremely poor solution for that. Say I have 150MB of art, sound, and music assets. Why should I be forced to copy them all to a separate directory just so people have marginally less trouble accessing and changing them? Plus, the save directory can be in pretty obscure locations depending on OS.
luaz
Citizen
Posts: 83
Joined: Sun Sep 16, 2012 2:55 pm

Re: How to load a file from game directory

Post by luaz »

What about game saves? What if the guy wants to play on multiple computers? It isn't practical to copy the WHOLE GAME to be able to do that, a simple game save folder weighting <1mb is much more practical.
If you're going to reply to my post, consider posting an (preferably working) example - 99.7% of time time, I already know how to implement the feature theoretically! ;) I don't learn very well from references, etc....
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 »

luaz wrote:What about game saves? What if the guy wants to play on multiple computers? It isn't practical to copy the WHOLE GAME to be able to do that, a simple game save folder weighting <1mb is much more practical.
Jesus, the pictures go inside the .love (or .exe - whatever); the saves go in the appdata folder.

love.filesystem can only write to the following: "Inside the .love"; "Inside the appdata folder"
Lua is not an acronym.
luaz
Citizen
Posts: 83
Joined: Sun Sep 16, 2012 2:55 pm

Re: How to load a file from game directory

Post by luaz »

qaisjp wrote:
luaz wrote:What about game saves? What if the guy wants to play on multiple computers? It isn't practical to copy the WHOLE GAME to be able to do that, a simple game save folder weighting <1mb is much more practical.
Jesus, the pictures go inside the .love (or .exe - whatever); the saves go in the appdata folder.

love.filesystem can only write to the following: "Inside the .love"; "Inside the appdata folder"
What if it's XP or older system? What if it's Linux or MacOS?
If you're going to reply to my post, consider posting an (preferably working) example - 99.7% of time time, I already know how to implement the feature theoretically! ;) I don't learn very well from references, etc....
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 »

luaz wrote:
qaisjp wrote:
luaz wrote:What about game saves? What if the guy wants to play on multiple computers? It isn't practical to copy the WHOLE GAME to be able to do that, a simple game save folder weighting <1mb is much more practical.
Jesus, the pictures go inside the .love (or .exe - whatever); the saves go in the appdata folder.

love.filesystem can only write to the following: "Inside the .love"; "Inside the appdata folder"
What if it's XP or older system? What if it's Linux or MacOS?
%appdata%... every system has a similar thing.
love.filesystem
This module provides access to Files in two places, and two places only:

The root folder of the .love archive (or source directory)
The root folder of the game's save directory.
Each game is granted a single directory on the system where files can be saved through love.filesystem. This is the only directory where love.filesystem can write files. These directories will typically be found in something like:

Windows XP: C:\Documents and Settings\user\Application Data\Love\ or %appdata%\Love\
Windows Vista and 7: C:\Users\user\AppData\Roaming\LOVE or %appdata%\Love\
Linux: $XDG_DATA_HOME/love/ or ~/.local/share/love/
Mac: /Users/user/Library/Application Support/LOVE/
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 »

Robin wrote:
OmarShehata wrote:(Unless you mean when distributing your game as a .love)
Yeah, this basically is about LAAP vs LAAF (LÖVE As A Platform/Framework). I might be a bit biased. :P
OmarShehata wrote:Also, keeping assets out of the exe can be useful especially if you want people to mod your game. Or update/edit graphics and other files without recompiling anything.
We have the save directory for that. :)
I guess this is the heart of the matter here is exactly LAAP vs LAAF.

I agree with slime that the love.filesystem leaves something to be desired. I agree it should be used whenever one can.

Like I said, as long as you exhaust all alternatives, I think it's fine to go with solutions that aren't entirely within the love philosophy. Sometimes one has to kill kittens to get the job done. (Now this is an argument of `do the ends justify the means`?)
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
Przemator
Party member
Posts: 107
Joined: Fri Sep 28, 2012 6:59 pm

Re: How to load a file from game directory

Post by Przemator »

What if I want to distribute the game as EXE, but would like users to create custom maps/levels/mods and share them? Then they would be forced to put the mod inside the save folder?
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: How to load a file from game directory

Post by Nixola »

Either that, or extract the .exe's contents, modify them and repacking it, and then distribute modified copies.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests