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

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.
TESLA
Prole
Posts: 2
Joined: Sun May 05, 2019 7:34 am

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

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

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

Post 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.
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.
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

Besides what zorg said, use forward slashes and you won't get the invalid escape sequence error. Also, backslashes are not portable.
Darlex
Party member
Posts: 128
Joined: Sun Sep 24, 2017 10:02 am
Location: Chile
Contact:

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

Post 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
Hi! I wish you have an amazing day!
Post Reply

Who is online

Users browsing this forum: No registered users and 85 guests