Binds: Difference between revisions
mNo edit summary |
|||
Line 152: | Line 152: | ||
==Examples== | ==Examples== | ||
=== Hook line always on=== | |||
===Hook line always on=== | |||
The command '''cl_show_hook_coll_own''', sets whether you will see your own hook collision line or not when you hold your '''+showhookcoll''' bind (defaulted to '''S'''). When set to '''2''', your hook collision line will always show only to you. Others players won't see it. | The command '''cl_show_hook_coll_own''', sets whether you will see your own hook collision line or not when you hold your '''+showhookcoll''' bind (defaulted to '''S'''). When set to '''2''', your hook collision line will always show only to you. Others players won't see it. | ||
'''hook_line_on.cfg''' | '''hook_line_on.cfg''' | ||
<span style="color:blue">cl_show_hook_coll_own</span> <span style="color:purple">2</span> | <span style="color:blue">cl_show_hook_coll_own</span> <span style="color:purple">2</span> | ||
<span style="color:purple"><span style="color:blue">cl_message_client_color</span> <span style="color:purple">green</span> | |||
<span style="color:blue">echo</span> <span style="color:purple">Hook Line ON</span> | <span style="color:blue">echo</span> <span style="color:purple">Hook Line ON</span> | ||
Line 168: | Line 164: | ||
'''hook_line_off.cfg''' | '''hook_line_off.cfg''' | ||
<span style="color:blue">cl_show_hook_coll_own</span> <span style="color:purple">1</span> | <span style="color:blue">cl_show_hook_coll_own</span> <span style="color:purple">1</span> | ||
<span style="color:purple"><span style="color:blue">cl_message_client_color</span> <span style="color:purple">red</span> | |||
<span style="color:blue">echo</span> <span style="color:purple">Hook Line OFF</span> | <span style="color:blue">echo</span> <span style="color:purple">Hook Line OFF</span> | ||
bind <span style="color:green">x</span> <span style="color:magenta">exec</span> <span style="color:blue">hook_line_on.cfg</span> | bind <span style="color:green">x</span> <span style="color:magenta">exec</span> <span style="color:blue">hook_line_on.cfg</span> | ||
Put both of these in the correct path, and in console: | Put both of these in the correct path, and in console: | ||
===bind <span style="color:green">x</span> <span style="color:magenta">exec</span> <span style="color:blue">hook_line_on.cfg</span>=== | |||
===Deep Fly=== | ===Deep Fly=== | ||
Line 195: | Line 194: | ||
Put both of these in the correct path, and in console: | Put both of these in the correct path, and in console: | ||
bind <span style="color:green">x</span> <span style="color:magenta">exec</span> <span style="color:blue">deepfly_on.cfg</span> | bind <span style="color:green">x</span> <span style="color:magenta">exec</span> <span style="color:blue">deepfly_on.cfg</span> | ||
===45° Aiming=== | |||
This bind allows you to only aim in 45° angles when holding down the key. This is useful for shooting rockets straight up for double rockets and a few other scenarios. | |||
bind <span style="color:green">x</span> <span style="color:red">"</span><span style="color:magenta">+toggle</span> <span style="color:blue">cl_mouse_max_distance</span> <span style="color:purple">2 400<span style="color:red">;</span> <span style="color:blue">inp_mousesens</span> <span style="color:purple">1 200</span><span style="color:red">;</span> <span style="color:blue">cl_show_hook_coll_own</span> <span style="color:purple">2 1<span style="color:red">"</span> | |||
Keep in mind that if you have changed '''cl_mouse_max_distance''' or '''inp_mousesens''' from the default, using the example above will | |||
==See also== | ==See also== | ||
*[https://forum.ddnet.tw/viewtopic.php?t=2537 Just bind it] - Useful binds available for copying | *[https://forum.ddnet.tw/viewtopic.php?t=2537 Just bind it] - Useful binds available for copying |
Revision as of 04:28, 2 August 2021
DDNet client has a multitude of commands and settings that can be bound to nearly any key or mouse button. You can enter commands into the console, which by default is accessed by pressing F1.
Syntax
Single binds
bind [key] [command/setting] [value]
This is the basic syntax for simple binds.
- [key] is the key on your keyboard/mouse you want to bind a command to.
- [command/setting] A full list of all commands and settings can be found here.
- [value] is the variable you want to set your setting to or an argument for a command. Not all commands require arguments
You can find keycodes here, or just type the key temporarily into one of the controls in the Settings > Controls page in DDNet client and it will show the key name. You can also use modifier keys with binds.
bind ctrl+[key] [command/setting] [value]
you can use ctrl, alt, and shift.
Multiple binds
You can also chain commands/settings together by separating them using a semicolon and wrapping them in quotes. You can add as many commands to this chain as you want.
bind [key] "[command/setting] [value]; [command/setting] [value]"
It's important to know that when chaining things together like this, all commands/settings get executed by the game at the exact same time, meaning they will not execute in the order you write them. There is no sleep or delay type command to space things out the way you want them. The best way to make things happen in an ordered sequence is to either bind a different key for each step of the sequence, or to use config files to press one key multiple times to read multiple files.
Nested binds
You can nest multiple quoted strings in a single line by escaping each new set of quotes with backslashes.
bind [key] "bind [key] \"[command/setting] [value]; bind [key] \\\"[command/setting] [value] \\\"\""
As the quoted strings go deeper, you also need to escape the backslash. Since each new layer will again un-escape them, you need to double the amount of backslashes per layer. The third layer will require 3 backslashes, the 4th will require 7, etc. If this is confusing to look at, try making a new line for each escaped quote to get a more clear visual idea of what's happening.
bind [key] "bind [key] \"[command/setting] [value]; bind [key] \\\"[command/setting] [value]; bind [key] \\\\\\\"[command/setting] [value] \\\\\\\" \\\" \" "
Client Commands
Toggles
Toggles are a way to use a single key to alternate between 2 values for a setting. There are two types of toggles.
- toggle is used so that each time you press a key, it will change between one of the two values for the setting
- +toggle is used so that your first value is set only while the key is being pressed, and the second value is set while the key is not being pressed.
bind [key] "toggle [setting] [value1] [value2]"
bind [key] "+toggle [setting] [value1] [value2]"
Toggles only work for client settings. They cannot be used for client or chat commands.
Say
Say is an important client command for binding. It allows you to incorporate chat commands into a bind as well as just send text to the chat.
bind [key] say /[chat command]
bind [key] say [chat message]
Exec
Exec is a useful client command for reading (executing) files which contain settings or commands
bind [key] exec [file]
Colors
Some client commands allow you to set colors.
- player_color_body
- player_color_feet
- cl_message_client_color
are a few examples.
To get the correct color values, go to Settings > Tee, and use the sliders to find the color you want. Go into the console and type the command for the color you're trying to set, by itself with no value. The number that comes after "Value:" is the relevant number.
player_color_body 5635840
It will also accept a few color values by name. red, yellow, green, blue, cyan, and magenta, all work.
Using Config Files
Syntax
For more complicated binds, you can make text files containing settings/commands that get executed via a key press.
settings.cfg
[command/setting] [value] [command/setting] [value] [command/setting] [value]; [command/setting] [value] [command/setting] [value]; [command/setting] [value] bind [key] [command/setting] [value] bind [key] exec [file.cfg]
Settings/commands can be chained together via a semicolon or by just using a new line. You can put as many commands/settings/binds as you want in these files.
Path/Exec
In order to execute these files, you need to put them in correct directory and execute them with the exec command. The correct path depends on your operating system.
Windows
%APPDATA%\Teeworlds\
MacOS
~/Library/Application\ Support/Teeworlds
Linux
~./Teeworlds
The standard file extension for these files is .cfg, but any other text file extension will work too. Once the files are in the correct path, you can execute them in the game console with the 'exec' command.
bind [key] exec [file.cfg]
You can use sub-directories within the 'Teeworlds' directory to organize files. Just include the path when you execute the file.
bind [key] exec [path/to/file.cfg]
Improved toggle with config files
The most common reason to use config files is to create a single-key toggle to alternate between two files.
file1.cfg
[command/setting] [value] [command/setting] [value] [command/setting] [value] bind [key] exec file2.cfg
file2.cfg
[command/setting] [value] [command/setting] [value] [command/setting] [value] bind [key] exec file1.cfg
In this case, [key] would be the same key in both files. This way each time you press the key, it will switch to the other file. Once you have both of these files in the correct path, you can exec either one just once and they will be bound forever until you unbind them.
bind [key] exec file1.cfg
You can use this method to cycle between any amount of files.
Customization
Echo
As a more clear way to show which file you're activating when you press a bind, you can use the echo command command to display which one is active.
[command/setting] [value] [command/setting] [value] echo setting ON bind [key] exec file1.cfg
To take this a step further, there is a command to change the color of the echo messages.
[command/setting] [value] [command/setting] [value] cl_message_client_color red echo setting OFF bind [key] exec file1.cfg
Having different colors for "on" and "off" binds makes it a bit easier to notice which setting you've activated.
Comments
You can put comments in your bind files too.
# These lines change some settings [command/setting] [value] [command/setting] [value] # This next line rebinds the key bind [key] exec file1.cfg
Examples
Hook line always on
The command cl_show_hook_coll_own, sets whether you will see your own hook collision line or not when you hold your +showhookcoll bind (defaulted to S). When set to 2, your hook collision line will always show only to you. Others players won't see it.
hook_line_on.cfg
cl_show_hook_coll_own 2 cl_message_client_color green echo Hook Line ON bind x exec hook_line_off.cfg
hook_line_off.cfg
cl_show_hook_coll_own 1 cl_message_client_color red echo Hook Line OFF bind x exec hook_line_on.cfg
Put both of these in the correct path, and in console:
bind x exec hook_line_on.cfg
Deep Fly
The deep fly bind is a way to make your dummy hammer/fire toward you whenever you fire with your main tee. If your dummy is deep frozen, they can hammer back at you when you hammer them with this bind on. You can use this to fly with your dummy, but it takes practice. If your dummy is not deep frozen, you can just use this as a alternative version of the regular Dummy Hammerfly bind included in the games settings, where you can fire your pistol each time you want to be hammered. It offers better control since you can control the timing of your dummy's hammers.
The command cl_dummy_hammer 1 is what is used for the regular Dummy Hammerfly bind in the games control options. By using a toggle, you can make your dummy hammer you only when you fire, and can make an on/off switch with config files.
deepfly_on.cfg
bind mouse1 "+fire; +toggle cl_dummy_hammer 1 0" cl_message_client_color green echo Deep Fly ON bind x exec deepfly_off.cfg
deepfly_off.cfg
bind mouse1 +fire cl_message_client_color red echo Deep Fly OFF bind x exec deepfly_on.cfg
Put both of these in the correct path, and in console:
bind x exec deepfly_on.cfg
45° Aiming
This bind allows you to only aim in 45° angles when holding down the key. This is useful for shooting rockets straight up for double rockets and a few other scenarios.
bind x "+toggle cl_mouse_max_distance 2 400; inp_mousesens 1 200; cl_show_hook_coll_own 2 1"
Keep in mind that if you have changed cl_mouse_max_distance or inp_mousesens from the default, using the example above will
See also
- Just bind it - Useful binds available for copying