Page 1 of 1

How to use values from conf.lua?

Posted: Sat Jun 07, 2014 4:51 am
by BoopDeePoop
I'm trying to check whether or not vsync is enabled and I get this error: "attempt to index global 't' (a nil value)

Code: Select all

	if t.window.vsync == true then
		love.graphics.print("vSync: Enabled",0,20)
	elseif t.window.vsync == false then
		love.graphics.print("vSync: Disabled",0,20)
	end
I'm probably doing something really stupid.

Re: How to use values from conf.lua?

Posted: Sat Jun 07, 2014 6:40 am
by Zilarrezko
I do know that "t" is actually just a local table in the conf function so I know that you can't access it by t.windows.vsync. That's why you're getting that error. If we found the table that the conf function passes on startup then I'm sure you could access it.

Other than that I can say that you could use the love.graphics.setMode() function in the love.load to set the vsync to false and from there store a variable somewhere that vsync is false. And just create a function so that everytime it's called it toggles vsync and changes the vsync to the opposite boolean value for displaying purposes.

Sorry I can't help ya more. But the big wigs know more about LÖVE's functions and structure than little young me here. Good Luck man.

Re: How to use values from conf.lua?

Posted: Sat Jun 07, 2014 7:29 am
by Robin
[wiki]love.window.getMode[/wiki]

Code: Select all

	local width, height, flags = love.window.getMode( )
	if flags.vsync then
		love.graphics.print("vSync: Enabled",0,20)
	else
		love.graphics.print("vSync: Disabled",0,20)
	end
or even:

Code: Select all

	local width, height, flags = love.window.getMode( )
	love.graphics.print(flags.vsync and "vSync: Enabled" or "vSync: Disabled",0,20)