How to know if the current sprite is new (unsaved)

Dear community, one can read in the docs (Sprite.filename):

Gets or sets the name of the file from where this sprite was loaded or saved. Or an empty string if this is a new sprite without an associated file.

However, the filename is not empty on a newly created sprite. Instead it follows the pattern Sprite-xxxx. The question is how to know if there is a file associated with the current sprite.

P.S. Of course, I can workaround that by checking if filename is a valid path but is there more reqular way ?

Thank you in advance !

It seems that

if not app.fs.isFile(sprite.filename) then
  app.alert('Sprite is not saved')
end

does the trick.

1 Like