function love.load()
imageLoc = "/resources/images/img1.png"
imgA=love.graphics.newImage(imageLoc)
end
function love.draw()
love.graphics.draw(imgA,0,0)
end
it runs perfectly in ZeroBrane IDE but when i compress it to .love file, i get an error: Could not open file... Does not exist.
Incidentally, when i try:
Windows doesn't care about uppercase and lowercase letters. So if you save something as PLAYER.PNG, and open it as "player.png" or "player.PNG" or "Player.png", it "works".
This is not the case for the rest of the systems. OSX, Linux, and, critically, ZIP files, don't do this "case conversion". That's why it "works on windows" but not anywhere else.
The solution is: make sure that your files and the path you use to load them are EXACTLY the same (my personal preference is always using lowercase for filenames and extensions).
kikito wrote:Windows doesn't care about uppercase and lowercase letters. So if you save something as PLAYER.PNG, and open it as "player.png" or "player.PNG" or "Player.png", it "works".
This is not the case for the rest of the systems. OSX, Linux, and, critically, ZIP files, don't do this "case conversion". That's why it "works on windows" but not anywhere else.
The solution is: make sure that your files and the path you use to load them are EXACTLY the same (my personal preference is always using lowercase for filenames and extensions).
thank you very much! it worked now.
but what if my target image location is outside my source folder like in my second problem. i think love or lua in general reads my string as:
sourceFolder..imageLocation
thats why it can't locate my image. what should i do about that?
jalamaya wrote:but what if my target image location is outside my source folder like in my second problem.
LÖVE does not allow reading things outside of the folder where main.lua is (or outside of the .love file) for security reasons. The only exception is the "data" folder, which is different for each system (windows, linux, osx). You can read more about this in [wiki]love.filesystem[/wiki]
jalamaya wrote:but what if my target image location is outside my source folder like in my second problem.
LÖVE does not allow reading things outside of the folder where main.lua is (or outside of the .love file) for security reasons. The only exception is the "data" folder, which is different for each system (windows, linux, osx). You can read more about this in [wiki]love.filesystem[/wiki]
since love2d has no open file dialog lib. i used love.textinput so the user will input the location of his desired image. does that mean if his desired image is not in the "data" folder, love will not read the image?
Users can drag-and-drop files and folders onto the game's window, and you can read them via [wiki]love.filedropped[/wiki] and [wiki]love.directorydropped[/wiki]. Other than that, love functions can't access paths outside of the game's source and save directories.