diff --git a/beatrun/gamemodes/beatrun/gamemode/cl/Keystrokes.lua b/beatrun/gamemodes/beatrun/gamemode/cl/Keystrokes.lua index 910daf4..a3c0053 100644 --- a/beatrun/gamemodes/beatrun/gamemode/cl/Keystrokes.lua +++ b/beatrun/gamemodes/beatrun/gamemode/cl/Keystrokes.lua @@ -7,39 +7,33 @@ local color_black_t = Color(0, 0, 0, 100) local size = 35 local function GetFormattedKey(bind) - string = input.LookupBinding(bind) + local keyBind = input.LookupBinding(bind) - if string == "MOUSE1" then string = "LMB" - elseif string == "MOUSE2" then string = "RMB" - elseif string == "MOUSE3" then string = "MMB" end + if keyBind == "MOUSE1" then keyBind = "LMB" + elseif keyBind == "MOUSE2" then keyBind = "RMB" + elseif keyBind == "MOUSE3" then keyBind = "MMB" end - if string then - return string.upper(string) + if keyBind then + return string.upper(keyBind) else - return "???" + return "?" end end local function ShowKeyStrokes() if showKeystrokes:GetBool() and GetConVar("Beatrun_HUDHidden"):GetInt() == 0 then - -- will have inconsistent indent on GH web view, thanks github - -- absolutely indented correctly, view in an editor like vscode - local forward = GetFormattedKey("+forward") - local back = GetFormattedKey("+back") - local moveleft = GetFormattedKey("+moveleft") - local moveright = GetFormattedKey("+moveright") - local use = GetFormattedKey("+use") - local reload = GetFormattedKey("+reload") - local jump = GetFormattedKey("+jump") - local speed = GetFormattedKey("+speed") - local duck = GetFormattedKey("+duck") - local attack = GetFormattedKey("+attack") - local attack2 = GetFormattedKey("+attack2") + local forward = GetFormattedKey("+forward") + local back = GetFormattedKey("+back") + local moveleft = GetFormattedKey("+moveleft") + local moveright = GetFormattedKey("+moveright") + local use = GetFormattedKey("+use") + local reload = GetFormattedKey("+reload") + local jump = GetFormattedKey("+jump") + local speed = GetFormattedKey("+speed") + local duck = GetFormattedKey("+duck") + local attack = GetFormattedKey("+attack") + local attack2 = GetFormattedKey("+attack2") - if attack == "MOUSE1" then attack = "LMB" end - if attack2 == "MOUSE2" then attack2 = "RMB" end - - -- Key W if LocalPlayer():KeyDown(IN_FORWARD) then surface.SetDrawColor(color_white_t) surface.DrawRect(size, 0, size, size) @@ -50,7 +44,6 @@ local function ShowKeyStrokes() draw.SimpleText(forward, "BeatrunHUD", size + 10, size - 30, color_white) end - -- Key E if LocalPlayer():KeyDown(IN_USE) then surface.SetDrawColor(color_white_t) surface.DrawRect(size * 2, 0, size, size) @@ -61,7 +54,6 @@ local function ShowKeyStrokes() draw.SimpleText(use, "BeatrunHUD", size + 48, size - 30, color_white) end - -- Key R if LocalPlayer():KeyDown(IN_RELOAD) then surface.SetDrawColor(color_white_t) surface.DrawRect(size * 3, 0, size, size) @@ -72,7 +64,6 @@ local function ShowKeyStrokes() draw.SimpleText(reload, "BeatrunHUD", size * 3 + 12, size - 30, color_white) end - -- Key A if LocalPlayer():KeyDown(IN_MOVELEFT) then surface.SetDrawColor(color_white_t) surface.DrawRect(0, size, size, size) @@ -83,7 +74,6 @@ local function ShowKeyStrokes() draw.SimpleText(moveleft, "BeatrunHUD", size - 23, size + 8, color_white) end - -- Key S if LocalPlayer():KeyDown(IN_BACK) then surface.SetDrawColor(color_white_t) surface.DrawRect(size, size, size, size) @@ -94,7 +84,6 @@ local function ShowKeyStrokes() draw.SimpleText(back, "BeatrunHUD", size + 12, size + 8, color_white) end - -- Key D if LocalPlayer():KeyDown(IN_MOVERIGHT) then surface.SetDrawColor(color_white_t) surface.DrawRect(size * 2, size, size, size) @@ -105,7 +94,6 @@ local function ShowKeyStrokes() draw.SimpleText(moveright, "BeatrunHUD", size + 48, size + 8, color_white) end - -- Space if LocalPlayer():KeyDown(IN_JUMP) then surface.SetDrawColor(color_white_t) surface.DrawRect(0, size * 2, size * 3, size) @@ -116,7 +104,6 @@ local function ShowKeyStrokes() draw.SimpleText(jump, "BeatrunHUD", 28, size * 2 + 8, color_white) end - -- Shift if LocalPlayer():KeyDown(IN_SPEED) then surface.SetDrawColor(color_white_t) surface.DrawRect(0, size * 3, size * 3, size) @@ -127,7 +114,6 @@ local function ShowKeyStrokes() draw.SimpleText(speed, "BeatrunHUD", 28, size * 3 + 8, color_white) end - -- Ctrl if LocalPlayer():KeyDown(IN_DUCK) then surface.SetDrawColor(color_white_t) surface.DrawRect(0, size * 4, size * 3, size) @@ -138,7 +124,6 @@ local function ShowKeyStrokes() draw.SimpleText(duck, "BeatrunHUD", 32, size * 4 + 8, color_white) end - -- Left Mouse if LocalPlayer():KeyDown(IN_ATTACK) then surface.SetDrawColor(color_white_t) surface.DrawRect(size * 3, size, size * 2, size) @@ -149,7 +134,6 @@ local function ShowKeyStrokes() draw.SimpleText(attack, "BeatrunHUD", size + 87, size + 8, color_white) end - -- Right Mouse if LocalPlayer():KeyDown(IN_ATTACK2) then surface.SetDrawColor(color_white_t) surface.DrawRect(size * 3, size * 2, size * 2, size)