Skip to content

Commit

Permalink
Fix missing logic for smart keybind
Browse files Browse the repository at this point in the history
  • Loading branch information
VickyFrenzy committed Sep 7, 2020
1 parent f289e97 commit 987e8e5
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions gamemodes/supercookingpanic/gamemode/cl_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,47 @@ local bind_text = {
}

local bind_check = {
["+attack"] = "MOUSE1",
["+attack2"] = "MOUSE2",
["+attack"] = {
name = "MOUSE1",
code = MOUSE_LEFT,
},
["+attack2"] = {
name = "MOUSE2",
code = MOUSE_RIGHT,
},
}

function GM:CheckBind(cmd)
--[[----------------------------------------------------------------------------
Name: GM:CheckForAltBind(cmd)
Desc: This function will enforce a more appropriate keybind,
if a player has multiple weird keybinds for some reasons.
------------------------------------------------------------------------------]]
function GM:CheckForAltBind(cmd)

local bind = bind_check[cmd]

local bind = input.LookupBinding(cmd, true)
if not bind then return nil end
if not bind.name then return nil end
if not bind.code then return nil end

if bind_check[cmd] then
if input.LookupKeyBinding(bind.code) then

bind = bind_check[cmd]
return bind_check[cmd].name

end

return nil

end

--[[----------------------------------------------------------------------------
Name: GM:CheckBind(cmd)
Desc: Returns a friendly translated bind input name from the cmd arg.
------------------------------------------------------------------------------]]
function GM:CheckBind(cmd)

local bind = self:CheckForAltBind(cmd) or input.LookupBinding(cmd, true)

if bind_text[bind] then

return language.GetPhrase(bind_text[bind])
Expand Down

0 comments on commit 987e8e5

Please sign in to comment.