I've just made my first (very simple, ugly) game in Love2D. The game works fine when run directly off my hard drive. However, when I package it up as a .love file, I get the following message:

Error: Could not open file resources/stormclouds.bmp. Does not exist.
stack traceback:
[C]: ?
[C]: in function 'newImage'
[string "main.lua"]:46: in function 'load'
[string "boot.lua"]:304: in function <[string "boot.lua"]:302>
[C]: in function 'xpcall'

The "resources" folder does exist within my directory structure (resources/stormclouds.bmp), and the game runs fine when its not packaged up.

The line of code responsible for this is:

bg = love.graphics.newImage("resources/stormclouds.bmp")

How can I make this line work for my packaged file?

  • 1
    \$\begingroup\$ You say that "resources" folder doesn't exist, but you still refer to it in code? What does the zip contents look like? There should be a resources directory in the zip and the .bmp file in the folder. \$\endgroup\$ – Jari Komppa Sep 22 '11 at 5:37
  • \$\begingroup\$ Yes, you're right, this was what the problem was. I had used the command given on the Love2d website to zip up my folder(zip ../${PWD##*/}.love *), but this doesn't seem to include sub folder contents. Zipping using a different method did solve this problem. \$\endgroup\$ – a_m0d Sep 22 '11 at 10:23
  • \$\begingroup\$ I'll formulate that into an answer.. \$\endgroup\$ – Jari Komppa Sep 22 '11 at 10:26

The .love files are actually renamed .zip files. These zip files contain directory structures, so if your code refers to, say, "foo/bar.dat", your zip file has to have a "foo" directory with the "bar.dat" contained within.

See http://love2d.org/wiki/Game_Distribution for details.

  • \$\begingroup\$ Yes, I was aware of this. The problem is that I ran zip ../${PWD##*/}.love * instead of zip -r ../${PWD##*/}.love *, which didn't recurse into sub folders. \$\endgroup\$ – a_m0d Sep 22 '11 at 13:31
  • 1
    \$\begingroup\$ The form of the answer was more for the next person who's looking for the answer, and ends up on this page. =) \$\endgroup\$ – Jari Komppa Sep 22 '11 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.