Page 1 of 1

Love2D can't find my files

Posted: Wed Apr 15, 2020 10:40 am
by Afrricyn
When I tried to make a font within my game it said that it could open my Font file even though it was in the correct place and even with audio files it can't seem to find my audio file as well.

https://stackoverflow.com/questions/60 ... font-file

This is the Audio code, I have also tried changing the path to sounds/name.wav - as the file sounds is with the main.lua file

Code: Select all

    sounds = {
        ["PongSE"] = love.audio.newSource("D:/VS - LUA/pong/sounds/PongSE.wav", "static"),
        ["win"] = love.audio.newSource("D:/VS - LUA/pong/sounds/win.wav","static"),
        ["wallhit"] = love.audio.newSource("D:/VS - LUA/pong/sounds/wallhit.wav", "static")
    }
This is my file directory
This is my file directory
love2d.png (321.97 KiB) Viewed 4481 times

Re: Love2D can't find my files

Posted: Wed Apr 15, 2020 11:20 am
by Optikon
So you tried this and it didn't work?:

Code: Select all

sounds = {
        ["PongSE"] = love.audio.newSource("sounds/PongSE.wav", "static"),
        ["win"] = love.audio.newSource("sounds/win.wav","static"),
        ["wallhit"] = love.audio.newSource("sounds/wallhit.wav", "static")
    }
Could you post a screenshot of the error, please?

Re: Love2D can't find my files

Posted: Wed Apr 15, 2020 1:56 pm
by pgimeno
Is it possible that you're running main.love instead of main.lua, and that main.love does not have the files? What happens if you remove main.love and run Löve passing the folder as argument?

Re: Love2D can't find my files

Posted: Thu Apr 16, 2020 1:03 pm
by Afrricyn
Yes, That's most likely the issue. How do I run Love and pass the folder as an argument?

Re: Love2D can't find my files

Posted: Thu Apr 16, 2020 2:20 pm
by zorg
Afrricyn wrote: Thu Apr 16, 2020 1:03 pm Yes, That's most likely the issue. How do I run Love and pass the folder as an argument?
https://love2d.org/wiki/Getting_Started#Windows

Alternatively, the way i like to do it: put the bold line, including quote marks, below, into an empty text file using notepad or your code editor of choice, change the paths to point to where your love.exe (or lovec.exe if you always want to have a command line open) is, and to where your project's folder/directory is. Not main.lua, the directory it is in.

"C:\Program Files\LOVE\love.exe" "C:\games\mygame"

save it as whatever, but i personally prefer to call it "mygame.bat" or just simply "run.bat"

doubleclicking that should work, no matter where that file is.

Re: Love2D can't find my files

Posted: Fri Apr 17, 2020 5:50 pm
by Afrricyn
Ye, Thanks all. Managed to fix the issue.