diff --git a/baton.lua b/baton.lua index 4cc1206..2b4b18d 100644 --- a/baton.lua +++ b/baton.lua @@ -66,19 +66,19 @@ local sourceFunction = {keyboardMouse = {}, joystick = {}} -- checks whether a keyboard key is down or not function sourceFunction.keyboardMouse.key(key) - return love.keyboard.isDown(key) and 1 or 0 + return love.keyboard ~= nil and love.keyboard.isDown ~= nil and love.keyboard.isDown(key) and 1 or 0 end -- checks whether a keyboard key is down or not, -- but it takes a scancode as an input function sourceFunction.keyboardMouse.sc(sc) - return love.keyboard.isScancodeDown(sc) and 1 or 0 + return love.keyboard ~= nil and love.keyboard.isScancodeDown ~= nil and love.keyboard.isScancodeDown(sc) and 1 or 0 end -- checks whether a mouse buttons is down or not. -- note that baton doesn't detect mouse movement, just the buttons function sourceFunction.keyboardMouse.mouse(button) - return love.mouse.isDown(tonumber(button)) and 1 or 0 + return love.mouse ~= nil and love.mouse.isDown ~= nil and love.mouse.isDown(tonumber(button)) and 1 or 0 end -- checks the position of a joystick axis