GetKeyBoundToFunction: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server client function}} | ||
getKeyBoundToFunction allows retrieval of the first key bound to a function. | getKeyBoundToFunction allows retrieval of the first key bound to a function. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <section name="Server" class="server" show="true"> | ||
string getKeyBoundToFunction( player thePlayer, function theFunction ) | <syntaxhighlight lang="lua">string getKeyBoundToFunction( player thePlayer, function theFunction )</syntaxhighlight> | ||
</syntaxhighlight> | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 14: | Line 13: | ||
===Returns=== | ===Returns=== | ||
Returns a string of the first key the function was bound to. | Returns a string of the first key the function was bound to. | ||
</section> | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua">string getKeyBoundToFunction( function theFunction )</syntaxhighlight> | |||
===Required Arguments=== | |||
*'''theFunction:''' The function in which you would like to check the bound key | |||
===Returns=== | |||
Returns a string of the first key the function was bound to. | |||
</section> | |||
==Example== | ==Example== | ||
<section name="Client" class="client" show="true"> | |||
/key command gives bounded key to our chat function | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function chat () | |||
outputChatBox("Test") | |||
end | |||
bindKey("F2","down",chat) | |||
function key() | |||
local boundKey = getKeyBoundToFunction(chat) | |||
outputChatBox(boundKey) | |||
end | |||
addCommandHandler("key",key) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
This example written by '''Samurai''' | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Input_functions}} | {{Input_functions}} | ||
Latest revision as of 11:20, 28 September 2013
getKeyBoundToFunction allows retrieval of the first key bound to a function.
Syntax
Click to collapse [-]
Serverstring getKeyBoundToFunction( player thePlayer, function theFunction )
Required Arguments
- thePlayer: The player you are checking the function bound to a key
- theFunction: The function in which you would like to check the bound key
Returns
Returns a string of the first key the function was bound to.
Click to collapse [-]
Clientstring getKeyBoundToFunction( function theFunction )
Required Arguments
- theFunction: The function in which you would like to check the bound key
Returns
Returns a string of the first key the function was bound to.
Example
Click to collapse [-]
Client/key command gives bounded key to our chat function
function chat () outputChatBox("Test") end bindKey("F2","down",chat) function key() local boundKey = getKeyBoundToFunction(chat) outputChatBox(boundKey) end addCommandHandler("key",key)
This example written by Samurai
See Also
- addCommandHandler
- bindKey
- executeCommandHandler
- getCommandHandlers
- getFunctionsBoundToKey
- getKeyBoundToFunction
- isControlEnabled
- removeCommandHandler
- toggleAllControls
- toggleControl
- unbindKey