keyboard.isDown multi key check not working?

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
bunktacular
Prole
Posts: 2
Joined: Fri Sep 16, 2011 2:02 am

keyboard.isDown multi key check not working?

Post by bunktacular »

I'm new to the LOVE engine and only lightly experienced in LUA, but I have a small little problem I would like to get the some help with, preferebly with reasoning so I can learn and improve.

Basically, I want to check if none of the game's control keys are held down.

Code: Select all

--slow down if no keys down
anyDown = love.keyboard.isDown( right, left, up, down )
if anyDown == false then
	yspeed = 0
end
According to this page, this command should return true or false, but it returns nil and causes
the game to crash before starting.

My error states that on that line: bad argument #1 to 'isDown' (string expected, got nil)
This all takes place within love.update.

Is there something little I am missing?
Is that function broken/bugged?
Am I being stupid with a much better method in doing this?
User avatar
TechnoCat
Inner party member
Posts: 1612
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: keyboard.isDown multi key check not working?

Post by TechnoCat »

Code: Select all

anyDown = love.keyboard.isDown( 'right', 'left', 'up', 'down' )
And anyDown will be true if any of those keys are pressed at any time.
bunktacular
Prole
Posts: 2
Joined: Fri Sep 16, 2011 2:02 am

Re: keyboard.isDown multi key check not working?

Post by bunktacular »

Alright, that fixed it.

Thank you very much, +1.


yspeed = 0 was just a placeholder so that I would know if it was working, the actual function will be much different.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: keyboard.isDown multi key check not working?

Post by Robin »

Note that any time LÖVE wants one of several named values (called Enums on the wiki), it means that those values are strings.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests