[Solved] Exit love.keypressed() function

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
unixfreak
Citizen
Posts: 82
Joined: Thu Oct 15, 2015 6:25 am
Location: Bristol, UK
Contact:

[Solved] Exit love.keypressed() function

Post 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.
Last edited by unixfreak on Mon Aug 06, 2018 12:23 am, edited 1 time in total.
User avatar
unixfreak
Citizen
Posts: 82
Joined: Thu Oct 15, 2015 6:25 am
Location: Bristol, UK
Contact:

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

Post 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!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 176 guests