Page 1 of 1

[Solved] Exit love.keypressed() function

Posted: Mon Aug 06, 2018 12:18 am
by unixfreak
Can anyone explain why this doesn't work?

Code: Select all

function love.keypressed(key)
	if console.active then
		console:keypressed(key)
		return --  <---should exit function here
	end

        player:keypressed(key)
        --[[
                other code etc.... than should only be run when console.active = false
        --]]

end
The problem is that the line with "return", should exit the function, and not process any other code when triggered. But even if console.active = true, then everything else gets run afterwards.

Re: Exit love.keypressed() function? Cannot figure this out

Posted: Mon Aug 06, 2018 12:23 am
by unixfreak
Derp. Ignore this post... i had some keypress input that was placed in some update() functions... hence they were triggering keypresses outside of the love.keypressed() function...

I ended up wrapping the keyboard related code in a block like:

Code: Select all

if not console.active then 
    -- blah blah
end
Solved!