How to load a file from game directory
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How to load a file from game directory
Sounds complicated, and yet very cool. I'm excited.
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....
- 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
"Forced" is a bit strong, but basically yes. Note that you (as lover) don't have to do anything for the save directory (except setting identity, and I believe LÖVE will use a reasonable default based on the file name of the .love or whatever if it's not given), so you could have regular maps, levels and whatever in the .love and folks can use the save directory to put their own maps, levels and mods and it will work automatically. (Although for mods you will usually want to provide some sort of framework or API to your game to make modding easier.)Przemator wrote: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?
Help us help you: attach a .love.
Re: How to load a file from game directory
This sounds reasonable. It's a shame though, that LOVE does not allow to write inside the game folder, where the EXE resides.Robin wrote:"Forced" is a bit strong, but basically yes. Note that you (as lover) don't have to do anything for the save directory (except setting identity, and I believe LÖVE will use a reasonable default based on the file name of the .love or whatever if it's not given), so you could have regular maps, levels and whatever in the .love and folks can use the save directory to put their own maps, levels and mods and it will work automatically. (Although for mods you will usually want to provide some sort of framework or API to your game to make modding easier.)
I just ran a quick test and this is what LOVE returns using the following functions:
Code: Select all
getAppdataDirectory: C:/Users/Przemek/AppData/Roaming
getSaveDirectory: C:/Users/Przemek/AppData/Roaming/LOVE/test
getUserDirectory: C:\Users\Przemek\
getWorkingDirectory: C:/Program Files (x86)/LOVE
- 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
Nope.Przemator wrote: So I guess the custom data goes to C:/Users/Przemek/AppData/Roaming/LOVE/test. I put main.lua inside a "test" folder, and LOVE used this name to create the save folder. Wonder if this can be changed, or does always game folder name = save folder name?
The name of the folder inside the AppData directory comes from what you have set in love.conf:
Code: Select all
function love.conf(t)
t.identity = 'MyGame'
end
Side note, you can have the same result using love.filesystem.setIdentity().
Re: How to load a file from game directory
Cheers, that's what I wantedRoland_Yonaba wrote:The name of the folder inside the AppData directory comes from what you have set in love.conf:
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: How to load a file from game directory
I've seen people complaing about this before, but you assume that this is good practice. Let's see, oh yeah, not everyone has their binaries next to their data (see linux). Barely anyone has write access to the directory programs are usually installed in (see windows, linux).Przemator wrote:It's a shame though, that LOVE does not allow to write inside the game folder, where the EXE resides.
Let's also illustrate the "badness" of this by looking at windows, and its wonderful ProgramData directory, showing off that everybody writing to Program Files is Doing It Wrong.
Re: How to load a file from game directory
I agree with bartbes. I keep my applications in /Applications and would prefer this directory not to be cluttered with save files and folders. Plus, I'm quite keen on seLöve and the security and peace of mind it has to offer, and wish to provide support for those that use it.
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.
- slime
- Solid Snayke
- Posts: 3163
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: How to load a file from game directory
In the case of OSX apps, everything is contained inside the .app, including the executable and all of the media and resources for most games. Save and settings information is stored in the usual places (Application Support or Documents).Lafolie wrote:I agree with bartbes. I keep my applications in /Applications and would prefer this directory not to be cluttered with save files and folders. Plus, I'm quite keen on seLöve and the security and peace of mind it has to offer, and wish to provide support for those that use it.
Bartbes: write access probably isn't a good idea, but read access definitely is in my opinion.
Re: How to load a file from game directory
Of course I knew this slime, but perhaps you're setting the scene for others too.
I don't see this being a problem so much anyway. If you would like to play it safe, use love.filesystem. If you prefer to have access to more locations and aren't afraid of any problems that may arise, use lua io. I'm not sure what drawbacks there may be with using standard io with löve though.
I don't see this being a problem so much anyway. If you would like to play it safe, use love.filesystem. If you prefer to have access to more locations and aren't afraid of any problems that may arise, use lua io. I'm not sure what drawbacks there may be with using standard io with löve though.
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.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: How to load a file from game directory
Maybe in a future release the appdata folder could be changed to the game folder or maybe use both so if I ran MyGame.love with the t.indentity set to MYGAMEFOLDER I would have
AppData/Roaming/LOVE/MYGAMEFOLDER
and
%Folder where my game is%/MYGAMEFOLDER
and I could select between both of them
Just an idea thought.
AppData/Roaming/LOVE/MYGAMEFOLDER
and
%Folder where my game is%/MYGAMEFOLDER
and I could select between both of them
Just an idea thought.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot] and 2 guests