Page 1 of 3

Created .exe, when running .exe error unable to load audio file

Posted: Fri Oct 09, 2020 6:08 am
by Nine Iron
Hey,

I tried searching for an answer, I thought I would have found one but I didn't. Please let me know if I missed a post.

I created an exe from a working project. I have my files but when I try to run the .exe it has an issue with the first audio file listed in my sound.lua. I tried copying all of my files into the same folder with the .exe, no success. What am I missing? I ran the console commands listed on the wiki, /b love.exe+game.love game.exe . I don't know what I'm missing. Any help would be greatly appreciated.



Thank you,

Nine Iron

Re: Created .exe, when running .exe error unable to load audio file

Posted: Fri Oct 09, 2020 12:18 pm
by ReFreezed
Make sure the audio files are in the .love file. All files for your game, except the .dll files, should be in the .love file.

Re: Created .exe, when running .exe error unable to load audio file

Posted: Fri Oct 09, 2020 1:49 pm
by Nine Iron
They are, I zipped everything inside the project folder 'as-is'. I must have changed something because now I'm getting the same error trying to run the program from the ide. Ugh, I swear it was working when I created the zip file.

I set up a function to automatically require all my files and it looks like it's trying to require my sound files. I'll move them to a different folder and figure out how to id the sound and picture files in a bit.

I appreciate the help.

Re: Created .exe, when running .exe error unable to load audio file

Posted: Fri Oct 09, 2020 1:56 pm
by pgimeno
Edit: never mind.

Re: Created .exe, when running .exe error unable to load audio file

Posted: Fri Oct 09, 2020 3:39 pm
by RNavega
Is this "unable to load audio file" the only info that the error screen gives you? That's kinda vague.
- It might fail if it can't find the file (bad relative path or no read permission).
- It might fail if it does find the file but the contents are corrupted.
- It might fail for some other reason I'm not aware of.

You can find some complete Love2D games over at itch.io and look inside their love archive. The Curse of The Arrow game, for example, has this structure...
  • CurseOfTheArrow-V1.8.3-universal.love/
    • main.lua (entry point)
      • /assets/
        • jump.wav
        • arrow.wav
        • sprites.png
        • ...
      • /src/
        • engine.lua
        • cutscene.lua
        • ...
    ...which then loads things like this:

    Code: Select all

    sfx = {
      ["step"] = love.audio.newSource("assets/step.wav","static"),
      ["jump"] = love.audio.newSource("assets/jump.wav","static"),
      ["hit"] = love.audio.newSource("assets/hit.wav","static"),
      ...
    }

    Re: Created .exe, when running .exe error unable to load audio file

    Posted: Fri Oct 09, 2020 4:47 pm
    by Nine Iron
    Okay, I reorganized my sound and picture files. My automated require function is no longer trying to require them. My program runs in the ide. When I create a zip and change .zip to .love, my program runs. When I create an exe though it will not run. As far I can see my archive has the same structure.

    I'm getting an error stating that it could not open my font file. 'Could not open file pics/font.tff. Does not exist.' The font is inside the pics folder. It traces back to a setNewFont function.

    If the .love runs fine, why won't the .exe? I tried moving it into my project folder, along with the love .dlls, and I get the same error.

    Re: Created .exe, when running .exe error unable to load audio file

    Posted: Fri Oct 09, 2020 10:45 pm
    by RNavega
    Are you sure that the .exe + .love fusion is being done properly? If you comment out that font loading, do the other assets load properly?

    Re: Created .exe, when running .exe error unable to load audio file

    Posted: Sat Oct 10, 2020 12:24 am
    by pgimeno
    Check the case of the filenames. In the case of a zip file, they must match.

    (That's the comment I deleted, I thought I was off the mark when I noticed that you said that it didn't work in the IDE either)

    Re: Created .exe, when running .exe error unable to load audio file

    Posted: Sat Oct 10, 2020 6:19 am
    by Nine Iron
    As far as the fusion, cmd says 1 file copied, no error. I can run the .love file just fine though. I run cmd with admin, cd to program files\love.

    I commented out the font mentions and now I get the original error for my sound file. It's not able to find the assets. It runs just fine, or at least loads, in the ide and the .love file. I now get an error from commenting out the fonts but that's after clicking a button. I can at least get the first room to load.

    The exe is the same name as the zip file. My main.lua is in the top tree of the zip.

    Re: Created .exe, when running .exe error unable to load audio file

    Posted: Sat Oct 10, 2020 11:24 am
    by pgimeno
    I bet if you move the .love file to another directory, it will give errors too. That's because it's still finding the files in your folder, out of the .love file (IIRC it doesn't search for them for fused programs).

    Check the letter case of the filename of the sound files and the font files, vs. what you have specified in the code. They must match.