Working around your problems will only cause more problems in the long run, so I'd suggest you fix them.
Having multiple actions bound to one key is possible, but you must establish a priority.
That is, if you press up your priority is to enter a room. If that's not possible, you can jump.
Code: Select all
function player.keypressed(key)
if key == "up" then
if not player.tryEnterRoom() then
if not player.tryJump() then
-- If we aren't allowed to jump for whatever reason we may want to try a different action
end
end
end
end
If you want your player to be able to be constantly jumping while holding the up key, you should instead be using love.keyboard.isDown.
Last but not least, to fix your "defining multiple callbacks" problem, you want to propagate events if they are not satisfied.
For example, when you click on screen you first want to tell your UI code there was a keypress.
It will return true if it "used" it, or false if it didn't click on anything.
If it returns false you can then propagate it to the next system, and the next and the next.
Code: Select all
function love.mousepressed(...)
if not menu.mousepressed(...) then
if not player.mousepressed(...) then
-- Etc
end
end
end
Hope that helps!