love.filesystem making a user accessible directory
love.filesystem making a user accessible directory
Say you want a game to use resources accessible to a user, such as screenshots, sounds, themes, saved games, etc. Where would you put/create folders for such resources? Seems odd that I have to use the user/library/Application Support, etc., directory, which is otherwise fine for a preference file. My first thinking is that I could run the app in a parent folder that contains such folders, but the love.filesystem doesn’t make access to that easy.
- slime
- Solid Snayke
- Posts: 3172
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: love.filesystem making a user accessible directory
You could provide a button or hotkey in your game to open the save directory, by using [wiki]love.system.openURL[/wiki] (there's an example of that on the function's wiki page.)
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: love.filesystem making a user accessible directory
The two easiest solutions:
Tell your users how to unzip the .love file (== distribute as source; if they run it unarchived, then that's that; they can access the internal folder structure of the project that's... no longer internal )
Either provide the assets your project needs separately, for the users to put in the save folder, or programatically place them in there at first startup of said project (cons: double space requirement) <- doubly good since you needn't separate code, but if you still want to, then you can always zip that part, and use love.filesystem.mount to access them from your project.
Some other things of interest:This returns the absolute path to either main.lua, or to the .love file that contains it.
If love.filesystem.mount could accept absolute (or relative paths that go "up" beyond the save or src directory trees), then it would be easy to accomplish what you want.
I wrote an ffi function that allowed one to change the writeable directory between the save folder, and the one where main.lua / the love file is. (only tested it on windows; apparently linux users have problems with one application having all types of needed files being contained in one folder... so from a security standpoint, this snippet is not that great) (I'll link it when i find it )
Tell your users how to unzip the .love file (== distribute as source; if they run it unarchived, then that's that; they can access the internal folder structure of the project that's... no longer internal )
Either provide the assets your project needs separately, for the users to put in the save folder, or programatically place them in there at first startup of said project (cons: double space requirement) <- doubly good since you needn't separate code, but if you still want to, then you can always zip that part, and use love.filesystem.mount to access them from your project.
Some other things of interest:
Code: Select all
love.filesystem.getRealDirectory('main.lua')
If love.filesystem.mount could accept absolute (or relative paths that go "up" beyond the save or src directory trees), then it would be easy to accomplish what you want.
I wrote an ffi function that allowed one to change the writeable directory between the save folder, and the one where main.lua / the love file is. (only tested it on windows; apparently linux users have problems with one application having all types of needed files being contained in one folder... so from a security standpoint, this snippet is not that great) (I'll link it when i find it )
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: love.filesystem making a user accessible directory
What Slime said. Minecraft puts its stuff in the Application Support folder too but includes a button to open the folder for drag and drop. It doesn't matter where stuff is kept as long as the user can get to it. Having a button is good enough.
Just make your game set its Identity directory at launch and create the proper folders if they don't exist and you're good to go.
Just make your game set its Identity directory at launch and create the proper folders if they don't exist and you're good to go.
Who is online
Users browsing this forum: No registered users and 5 guests