Page 1 of 1

love.conf not working?

Posted: Sat Mar 04, 2023 12:37 pm
by RisuTheGrate
Hi everyone, so I have a conf.lua file where I put my love.conf function in. But when I require the file in main.lua, everything I wrote inside conf.lua seems to be ignored. I'm not sure why. Here is my file structure:

Image

And here is the code inside conf.lua and main.lua respectively:

Code: Select all

-- Code in conf.lua
function love.conf(t)
    t.window.with = 1280
    t.window.height = 720
end

Code: Select all

-- Code in main.lua
function love.load()
    require("Conf.conf")
    require("Objects.mainCharacter")
    require("Objects.rect")
    require("Objects.floor")

    love.window.setTitle("Object Follow Test")
end

function love.update(dt)
    mainCharacter:update(dt)
    rect:update()
    floor:update()
end

function love.draw()
    mainCharacter:draw()
    rect:draw()
    floor:draw()
end
Any help is appreciated!

Re: love.conf not working?

Posted: Sat Mar 04, 2023 2:08 pm
by Bigfoot71
The conf.lua file must be in the same directory as the main.lua and you don't need to call it with require, love2d loads it automatically.

Additionally you can also set the window name in conf.lua like this:

Code: Select all

function love.conf(t)
    t.window.title = "My awesome game name"
end
https://love2d.org/wiki/Config_Files

Re: love.conf not working?

Posted: Sat Mar 04, 2023 2:10 pm
by RisuTheGrate
Do I still have to require the conf.lua file?

Re: love.conf not working?

Posted: Sat Mar 04, 2023 2:11 pm
by Bigfoot71
Sorry I just edited it, no you don't need it, love2d loads it automatically.

Re: love.conf not working?

Posted: Sat Mar 04, 2023 2:14 pm
by RisuTheGrate
Okay, thank you for the help!