• Suggestion: Add a bind lookup function!
    8 replies, posted
Wasn't sure where to post this but I saw an update thread here so thought it might be ok. So I came across this thread today - [url]https://facepunch.com/showthread.php?t=1348923&p=44380255&viewfull=1#post44380255[/url] And found it really useful so was wondering if it could be added to the game so I don't have to paste a massive table in every script I want to check binds on! Thanks.
[url]http://wiki.garrysmod.com/page/input/GetKeyName[/url] ????
I have this: [code] local _key = "KEY_" .. string.upper(input.LookupBinding( "PC_menu" )); if ( input.IsKeyDown( BIND_KEY_NUMBERS[ _key ] ) ) then [/code] So with GetKeyName I tried [code] lua_run_cl print(input.GetKeyName(input.LookupBinding( "PC_menu"))) [/code] And that didn't work. Maybe I'm doing it wrong? [ERROR] LuaCmd:1: bad argument #1 to 'GetKeyName' (number expected, got string) 1. GetKeyName - [C]:-1 2. unknown - LuaCmd:1 Even tried this: [code] lua_run_cl print(input.GetKeyName( "KEY_" .. string.upper(input.LookupBinding( "PC_menu" )))) [/code] Same error. It's so that you can bind the menu's console command to a key and still close the menu when it's open using the bound key.
By looking at the error, you can clearly see it is not looking for a string as it's argument.
bump. I need this again, can anyone help please?
[QUOTE=Hackcraft;51279277]bump. I need this again, can anyone help please?[/QUOTE] [URL="http://wiki.garrysmod.com/page/input/LookupBinding"]http://wiki.garrysmod.com/page/input/LookupBinding[/URL] ?
That only says if it's bound. I'm trying to get the KEY_ENUM for bind checking but LookupBinding only returns the key and idk how to convert it without using a huge table to do it for me.
Why do you need the Key_ENUM Also you can do string.byte on the characters returned...If A is 65, B is 66, KEY_A is 11 and KEY_B is 12...You have to use your brain...
[QUOTE=Hackcraft;51279476]That only says if it's bound. I'm trying to get the KEY_ENUM for bind checking but LookupBinding only returns the key and idk how to convert it without using a huge table to do it for me.[/QUOTE] [code]local key = _G["KEY_" .. input.LookupBinding("PC_menu"):upper()][/code]
Sorry, you need to Log In to post a reply to this thread.