function makeKeyCombo( ... )
return function()
for i = 1, select('#', ...) do
if not love.keyboard.isDown(select(i, ...)) then return false end
end
return true
end
end
ctrld = makeKeyCombo( "lctrl", "d" )
function love.update(dt)
if ctrld() then print("Nice.") end
end
Just an idea, but probably not very good as the lctrl and rctrl difference might be a problem.
EDIT: Oops, the vararg can't be captured by the closure, so that code won't work.
function makeKeyCombo( ... )
local keys = {...}
return function()
for i = 1, #keys do
if not love.keyboard.isDown(keys[i]) then return false end
end
return true
end
end
Last edited by Inny on Tue Mar 06, 2012 5:34 am, edited 1 time in total.
if Key "ctrl" + Key "space" then end -- overengineered way of 'ctrl down and space down'
if Key "ctrl" - Key "space" then end -- ditto for 'ctrl down and not space down'
if Key "ctrl" / Key "space" then end -- ditto for 'ctrl down or space down'
if Key "ctrl" ^ Key "space" then end -- slightly more useful (in the few cases you'd ever need it i guess), 'ctrl down xor space down'
if Key "ctrl" < Key "space" then end -- 'ctrl down and space down, but ctrl was pressed first'
if #Key "ctrl" >= 5 then end --'ctrl held down for 5 or more time units (whatever you're using for those)'
Ohh, yeah, sorry. That makes more sense. Sometimes, once maybe every few years, I'll do something stupid. You should consider yourself lucky you expirienced one of these... 'rare'... events.
>.>
<.<