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-19 15:13:13 +00:00
|
|
|
Keybind.editor = {}
|
2022-01-29 07:49:45 +00:00
|
|
|
Keybind.generic = {}
|
2022-01-17 23:14:54 +00:00
|
|
|
|
2022-01-19 13:55:15 +00:00
|
|
|
function Keybind:CheckDown(action)
|
|
|
|
for _, keyname in pairs(action.keys) do
|
2022-01-18 15:49:49 +00:00
|
|
|
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-19 13:55:15 +00:00
|
|
|
function Keybind:HasPressed(action)
|
|
|
|
if Keybind:CheckDown(action) then
|
|
|
|
if not action.pressed then
|
|
|
|
action.pressed = true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
else
|
2022-01-19 13:58:49 +00:00
|
|
|
action.pressed = nil
|
2022-01-19 13:55:15 +00:00
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function Keybind:CheckCollision(cat, key)
|
2022-01-18 19:47:55 +00:00
|
|
|
for _, action in pairs(cat) do
|
2022-01-19 13:55:15 +00:00
|
|
|
for _, keyname in pairs(action.keys) do
|
2022-01-18 19:47:55 +00:00
|
|
|
if key == keyname then return true end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2022-01-19 13:55:15 +00:00
|
|
|
function Keybind:AddKey(action, key)
|
|
|
|
table.insert(action.keys, key)
|
2022-01-18 19:47:55 +00:00
|
|
|
end
|
|
|
|
|
2022-01-19 13:55:15 +00:00
|
|
|
function Keybind:ChangeKey(action, position, key)
|
|
|
|
action.keys[position] = key
|
2022-01-18 19:47:55 +00:00
|
|
|
end
|
|
|
|
|
2022-01-19 13:55:15 +00:00
|
|
|
function Keybind:RemoveKeys(action)
|
|
|
|
action.keys = {}
|
2022-01-18 19:47:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function Keybind:Default()
|
2022-01-19 12:28:09 +00:00
|
|
|
--Menu
|
2022-01-19 13:55:15 +00:00
|
|
|
Keybind.menu.pause= { keys = {"escape"}}
|
2022-02-01 14:05:36 +00:00
|
|
|
Keybind.menu.confirm= { keys = {"z", "space", 1}}
|
2022-02-10 17:18:37 +00:00
|
|
|
|
2022-01-19 12:28:09 +00:00
|
|
|
--Move
|
2022-01-19 13:55:15 +00:00
|
|
|
Keybind.move.left = { keys = {"left", "a"}}
|
|
|
|
Keybind.move.right = { keys = {"right", "d"}}
|
|
|
|
Keybind.move.up = { keys = {"up", "w"}}
|
|
|
|
Keybind.move.down = { keys = {"down", "s"}}
|
|
|
|
Keybind.move.jump = { keys = {"z", "space"}}
|
2022-02-10 17:18:37 +00:00
|
|
|
Keybind.move.hook = { keys = {"x", 1}}
|
2022-01-19 13:55:15 +00:00
|
|
|
Keybind.move.dash = { keys = {"c", 2}}
|
2022-02-10 17:18:37 +00:00
|
|
|
|
2022-01-19 12:28:09 +00:00
|
|
|
--Debug
|
2022-01-19 13:55:15 +00:00
|
|
|
Keybind.debug.debug = { keys = {"f1"}}
|
|
|
|
Keybind.debug.reposition = { keys = {"f2"}}
|
|
|
|
Keybind.debug.reload = { keys = {"f3"}}
|
|
|
|
Keybind.debug.editor = { keys = {"f4"}}
|
2022-02-10 17:18:37 +00:00
|
|
|
|
2022-01-19 15:13:13 +00:00
|
|
|
-- Editor
|
|
|
|
Keybind.editor.palette = { keys = {"tab"}}
|
2022-01-29 07:49:45 +00:00
|
|
|
|
|
|
|
-- Generic
|
|
|
|
Keybind.generic.lclick = { keys = {1}}
|
|
|
|
Keybind.generic.rclick = { keys = {2}}
|
2022-01-31 00:22:15 +00:00
|
|
|
Keybind.generic.lshift = { keys = {"lshift"}}
|
|
|
|
Keybind.generic.lctrl = { keys = {"lctrl"}}
|
2022-01-18 19:47:55 +00:00
|
|
|
end
|
2022-01-18 15:49:49 +00:00
|
|
|
|
2022-01-18 19:47:55 +00:00
|
|
|
-- Set default values at start
|
|
|
|
Keybind:Default()
|