I am looking at the wiki and I don't quite see anything regarding opening a window to select and load a new file. Is that possible in love2d because it wasn't last time i was here which was probably around 9.x.
Do we still need to generate files within the application and save them in the application's default save directory?
File Open
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: File Open
File select dialogs are related to the operating system - the focus behind love2d is to make games playable across multiple platforms, including iOS and Android. OS-related things like this are probably not going to happen (at least not in the foreseeable future).
Yes, you always want to write to the AppData folder, it would be unsafe to save files elsewhere.
Yes, you always want to write to the AppData folder, it would be unsafe to save files elsewhere.
-
- Party member
- Posts: 234
- Joined: Mon Aug 29, 2016 8:51 am
Re: File Open
I've always wondered, what's so special for the appdata? Why is it safe? How is it different than any other folder on my hard drive?
- zorg
- Party member
- Posts: 3476
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: File Open
Let me preface my message by stating that i don't agree with how OS-es coddle people and not allow them to do whatever the absolute hell they want to their own (file)system. And i don't agree with the unsafe argument (at least partially), because last i checked, tons of applications can access and write to directories all around the filesystem; Composing software, Drawing programs, not to mention 3rd party file managers.
File dialog windows, ones given to you by the system that is, are hard to access and get to work (and they are OS-specific too, so you'd need to code it more than once per platform through the FFI, if you even could); Accessing any other part of the filesystem though was always possible, through lua's own io system. (At least back in the day of 0.7.x onwards, that's when i joined, so i can't say if it was possible before, but it probably was)
That said, i'm working on a lib (with the FFI as well) to allow you to access any place on your filesystem through love.filesystem as well (granted it may be limited in usage if your OS would block your app from accessing certain directories), and with that, one could write a graphical element akin to a file dialog window, so that they could access any files anywhere.
Downside is that if you compile löve against anything but luaJIT, my lib won't work.
Writing files would be harder to implement though, by way of PhysFS (that löve uses) can only ever have one simultaneous write-directory, and if you wanted to write to more locations, or keep files opened for writing, it would fail to dynamically change said write-directory. I'm still thinking about whether i should just code around that, or use lua's io functions for saving/writing data.
Finally, since löve is more or less an educational tool in my mind, helping people make games being the most common denominator, i still believe it's fair that its own filesystem implementation has such limits; at least you can know that by default, these projects won't litter your filesystem with files, but it still gives you ways to go around said limits.
File dialog windows, ones given to you by the system that is, are hard to access and get to work (and they are OS-specific too, so you'd need to code it more than once per platform through the FFI, if you even could); Accessing any other part of the filesystem though was always possible, through lua's own io system. (At least back in the day of 0.7.x onwards, that's when i joined, so i can't say if it was possible before, but it probably was)
That said, i'm working on a lib (with the FFI as well) to allow you to access any place on your filesystem through love.filesystem as well (granted it may be limited in usage if your OS would block your app from accessing certain directories), and with that, one could write a graphical element akin to a file dialog window, so that they could access any files anywhere.
Downside is that if you compile löve against anything but luaJIT, my lib won't work.
Writing files would be harder to implement though, by way of PhysFS (that löve uses) can only ever have one simultaneous write-directory, and if you wanted to write to more locations, or keep files opened for writing, it would fail to dynamically change said write-directory. I'm still thinking about whether i should just code around that, or use lua's io functions for saving/writing data.
Finally, since löve is more or less an educational tool in my mind, helping people make games being the most common denominator, i still believe it's fair that its own filesystem implementation has such limits; at least you can know that by default, these projects won't litter your filesystem with files, but it still gives you ways to go around said limits.

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.

Who is online
Users browsing this forum: No registered users and 4 guests