Page 1 of 1
How to get the source filename of a loaded Image?
Posted: Sat May 30, 2020 9:52 pm
by gusg21
I'm trying to make a built-in editor for my game and therefore I need it to save new entities which in turn need to save whatever image they're using, but I'm having trouble serializing an image effectively. The way I'd like to do it would be to simply save the path to the image file, but it doesn't look like there's any Image:getSource() function. Any alternatives are also welcome. Thanks!
Re: How to get the source filename of a loaded Image?
Posted: Sun May 31, 2020 7:30 am
by MadByte
There is
(File):getFilename which returns the full file path when a files is dropped onto the game window. If you don't use filedropped, you most likely would need to implement some kind of file browser, where users can navigate to the desired file and select it - then use the path the user navigated to and store it as variable to write it to your save file later.
Re: How to get the source filename of a loaded Image?
Posted: Sun May 31, 2020 9:16 am
by zorg
You can use a library to support arbitrary paths in your editor:
https://github.com/megagrump/nativefs
It's easier, in comparison to implementing image encodings löve can read but not write (all but png).