Page 1 of 1

Dumb question : Love.config(t)

Posted: Sun Jun 04, 2017 2:58 pm
by SatoKato
Hello, I created a config.lua with this code:

Code: Select all

function love.conf(t)
    t.window.width = 1280
    t.window.height = 720  
    t.modules.joystick = false
    end
Is there a way to call it in main.lua? :o

thanks for your times!

Re: Dumb question : Love.config(t)

Posted: Sun Jun 04, 2017 4:54 pm
by Sir_Silver
Not 100% sure on this, but I think you just need to call it conf.lua and have it in the same folder as main.lua and it should work without having to call require yourself.

Re: Dumb question : Love.config(t)

Posted: Sun Jun 04, 2017 6:25 pm
by yetneverdone
SatoKato wrote: Sun Jun 04, 2017 2:58 pm Hello, I created a config.lua with this code:

Code: Select all

function love.conf(t)
    t.window.width = 1280
    t.window.height = 720  
    t.modules.joystick = false
    end
Is there a way to call it in main.lua? :o

thanks for your times!
lua also checks for a file named conf.lua, if that exists, lua will automatically run that. So no worries :)

Re: Dumb question : Love.config(t)

Posted: Sun Jun 04, 2017 6:44 pm
by SatoKato
yetneverdone wrote: Sun Jun 04, 2017 6:25 pm
SatoKato wrote: Sun Jun 04, 2017 2:58 pm Hello, I created a config.lua with this code:

Code: Select all

function love.conf(t)
    t.window.width = 1280
    t.window.height = 720  
    t.modules.joystick = false
    end
Is there a way to call it in main.lua? :o

thanks for your times!
lua also checks for a file named conf.lua, if that exists, lua will automatically run that. So no worries :)
Thank you!

Re: Dumb question : Love.config(t)

Posted: Sun Jun 04, 2017 9:07 pm
by Nixola
Lua does not do that; LÖVE does. (Lua also doesn't automatically look for any file; that's still LÖVE.)

Re: Dumb question : Love.config(t)

Posted: Sun Jun 04, 2017 10:50 pm
by zorg
Since conf.lua is loaded before main.lua is (and by that time, the modules would have been loaded), you can't exactly define the conf function in main.lua... what you can do though, is defer window creation from conf.lua to somewhere else (like love.load in your main.lua or wherever):

Code: Select all

-- In conf.lua (I'm leaving out stuff...)

t.window = false -- Don't create a graphical window just yet...

-- In another file, let's say main.lua for example

function love.load(args)
    -- Create the window
    love.window.setMode(800, 600, {vsync=false})
end
This is neat if you need to parse stuff after conf.lua and only create the window after, based on that data... meaning it won't flash the window twice this way, which would be annoying.

Re: Dumb question : Love.config(t)

Posted: Mon Jun 05, 2017 1:50 am
by yetneverdone
Nixola wrote: Sun Jun 04, 2017 9:07 pm Lua does not do that; LÖVE does. (Lua also doesn't automatically look for any file; that's still LÖVE.)
Oh yeah, i mixed lua and love always. Thanks for clarifying