Mothback/data/scripts/keybind.lua

58 lines
1.2 KiB
Lua
Raw Normal View History

2022-01-18 19:47:55 +00:00
Keybind = {}
Keybind.move = {}
Keybind.menu = {}
2022-01-19 12:54:33 +00:00
Keybind.debug = {}
2022-01-18 19:47:55 +00:00
function Keybind:Check(action)
for _, keyname in pairs(action) do
if type(keyname) == "string" then
if love.keyboard.isDown(keyname) then return true end
else
if love.mouse.isDown(keyname) then return true end
end
end
return false
end
2022-01-18 19:47:55 +00:00
function Keybind:Colision(cat, key)
for _, action in pairs(cat) do
for _, keyname in pairs(action) do
if key == keyname then return true end
end
end
return false
end
function Keybind:Add(action, key)
table.insert(action, key)
end
function Keybind:Change(action, position, key)
action[position] = key
end
function Keybind:Remove(action)
action = {}
end
function Keybind:Default()
--Menu
2022-01-19 12:54:33 +00:00
Keybind.menu.pause = {"escape"}
--Move
2022-01-18 19:47:55 +00:00
Keybind.move.left = {"left", "a"}
Keybind.move.right = {"right", "d"}
Keybind.move.up = {"up", "w"}
Keybind.move.down = {"down", "s"}
Keybind.move.jump = {"z", "space"}
Keybind.move.attack = {"x", 1}
Keybind.move.dash = {"c", 2}
--Debug
Keybind.debug.debug = {"f1"}
Keybind.debug.reposition = {"f2"}
Keybind.debug.reload = {"f3"}
Keybind.debug.editor = {"f4"}
2022-01-18 19:47:55 +00:00
end
2022-01-18 19:47:55 +00:00
-- Set default values at start
Keybind:Default()