How to get the source filename of a loaded Image?

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.
Post Reply
User avatar
gusg21
Prole
Posts: 1
Joined: Fri Mar 30, 2018 1:44 pm
Contact:

How to get the source filename of a loaded Image?

Post 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!
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: How to get the source filename of a loaded Image?

Post 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.
User avatar
zorg
Party member
Posts: 3449
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to get the source filename of a loaded Image?

Post 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).
Me and my stuff :3True 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests