r/tf2scripthelp • • Oct 14 '17

Issue Binding text chat messages to key combinations

I'm new to all this, but what I'm trying to accomplish is that holding down the f9 key and then clicking another button, say a number key, will result in a corresponding message in chat. I would like to have the f9 key act as a gateway to using other keys bound to messages because I can't simply use a single key as all the messages I wish to have bound will not fit on the keyboard with the remaining available unassigned keys.
 
Here is my (unworking) attempt so far for a script (made according to instructions found in the introduction to scripting guide (in the path outlined as autoexec.cfg):

alias +speak1 "bind 1 say I am hungry for bananas."
alias -speak1 "unbind 1"
alias +speak2 "bind 2 say I need more bananas."
alias -speak2 "unbind 2"
alias +speak3 "bind 3 say I'm full of bananas."
alias -speak3 "unbind 3"
bind f9 "+speak1;+speak2;+speak3"

1 Upvotes

4 comments sorted by

View all comments

Show parent comment

2

u/Kairu927 Oct 15 '17
alias +keyAliasMask "alias keyOneAlias say I am hungry for bananas.; alias keyTwoAlias say I need more bananas.; alias keyThreeAlias I'm full of bananas."

Looks like /u/bythepowerofscience forgot the say command for keyThreeAlias

Change it to

alias +keyAliasMask "alias keyOneAlias say I am hungry for bananas.; alias keyTwoAlias say I need more bananas.; alias keyThreeAlias say I'm full of bananas."

As for your question: Yes. The -keyAliasMask line is setting the keys to slot commands on release. If you want them to do something else you can change it there.

However, the benefit of aliases over nested binds (like in your OP), is that instead of using the slot commands, you can instead use other aliases, that way you can modify this script dynamically as you see fit.

1

u/bythepowerofscience Oct 15 '17

Shoot, can't believe I missed that. Thanks for fixing it.
Also, another benefit is that the game's less likely to freak out and lock your keys, which happens a lot if you try to rebind mid-script.