Page 2 of 2

Re: Is there a way of saving and loading files from anywhere?

Posted: Mon May 06, 2019 5:41 am
by TESLA
Hey guys I need help!
I'm trying to upload a png file with the name blocky.png. My love.exe file is in the C: drive and this is how I tried loading it.

Code: Select all

local heroman
function love.load()
heroman = love.graphics.newImage("C:\Users\Kazabite\Desktop\Engine\gfx\blocky.png")
end
where Kazabite is the user name, Engine is the file where main.lua is present and gfx where the png file is located.
However, I get an error that there is an invalid escape sequence near '"C;'

Can anyone help plz?

Re: Is there a way of saving and loading files from anywhere?

Posted: Mon May 06, 2019 9:41 am
by zorg
You mean you're trying to load it, not upload it.

And by default, that's not going to work, löve only supports relative paths from where your main.lua is, and the project's save directory; It does not support absolute paths like what you are trying. (hence why i linked you to this thread if absolute paths would be a necessity to you; clearly they aren't)

Do use the wiki, that's why it's there: https://love2d.org/wiki/love.filesystem

But, assuming that your main.lua is in the Engine folder, you'd do love.graphics.newImage("gfx\blocky.png") and that should work.

Re: Is there a way of saving and loading files from anywhere?

Posted: Mon May 06, 2019 10:25 am
by pgimeno
Besides what zorg said, use forward slashes and you won't get the invalid escape sequence error. Also, backslashes are not portable.

Re: Is there a way of saving and loading files from anywhere?

Posted: Wed May 08, 2019 4:10 pm
by Darlex
ivan wrote: Sun May 05, 2019 5:12 pm
Darlex wrote: Sun May 05, 2019 4:47 pm I want to give that sensation of comfort of saving and loading files from anywhere to anywhere.
Frankly speaking, I don't see anything "comfortable" in dealing with file dialogs, etc.
In fact, most modern programs never ask you to browse around the device's filesystem.
A good example would be apps on Android and iOS.
Im not thinking about creating a game editor for android or ios