Engine:CCMD bind: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
A 'bind' acts like a custom command for a key. It runs the assigned text as a script, which can contain a single-word command, statement, or script. | A 'bind' acts like a custom command for a key. It runs the assigned text as a script, which can contain a single-word command, statement, or script. | ||
By default, binds do not work while input is in console or in text mode. | |||
== Examples == | == Examples == | ||
Line 21: | Line 19: | ||
* Check alias 'bob' for script value. No alias exists named 'bob'. | * Check alias 'bob' for script value. No alias exists named 'bob'. | ||
<kua> | <kua> | ||
> | > bind Z | ||
Unknown: bob | Unknown: bob | ||
</kua> | </kua> |
Revision as of 00:46, 15 October 2023
Creates a new key binding, replacing existing key binding if any.
bind Z "echo fred"
Arguments
- name - name of binding, which corresponds to a particular key, button, or other device.
- value (optional) - script string or command to run. If not supplied, then prints the script or command value, if the binding exists.
Associations
- Key bindings are global, and not a part of any context.
Details
A 'bind' acts like a custom command for a key. It runs the assigned text as a script, which can contain a single-word command, statement, or script.
By default, binds do not work while input is in console or in text mode.
Examples
Default values
- Check alias 'bob' for script value. No alias exists named 'bob'.
> bind Z Unknown: bob
- Call 'bob'. No command, variable or alias named 'bob' exist.
> bob Unknown: bob
- Create an alias 'bob' and set to 'echo fred'.
> alias bob "echo fred"
- Same as the second example, but now alias 'bob' exists. The 'echo' command in the 'bob' alias script runs, and prints 'fred'.
> bob fred
- Same as the first example, but now alias 'bob' exists and shows the value of the alias 'bob'
> alias bob
'bob' is 'echo fred'
To a variable
- 'bob' called without a value. No command, variable or alias named 'bob' exist.
> bob Unknown: bob
- Create an alias 'bob' and set to 'fred'.
> alias bob fred
- Same as the first example, but now alias 'bob' exists. The 'fred' command in the 'bob' alias script runs, and 'fred' doesn't exist.
> bob Unknown: fred
- Create variable 'fred'.
> var fred james
- Run 'bob'
> bob
'fred' is 'james'
- Try to set 'fred' through 'bob'. Value remains the same because 'bob' is only the statement "fred".
> bob alan
> bob
'fred' is 'james'