r/tf2scripthelp • • Jul 11 '14

Issue Help with bind toggling

I am currently trying to use one key to give me multiple other abilitys with the keyboard. This is my work currently, yet it shows in the consol "bind: bind a key" or whatever, so I must have written something wrong. Any assitance?

bind alt toggle

alias toggle "enable"

alias enable "alias toggle disable;bind x +movedown;bind c +moveup;bind 1 voicemenu 0 0;bind 2 voicemenu 0 1;bind 3 voicemenu 1 3;bind 4 voicemenu 1 4;bind 5 voicemenu 1 5;bind 6 voicemenu 1 6;bind q voicemenu 2 2;bind e voicemenu 2 4;bind r voicemenu 2 3;bind t voicemenu 2 5;bind n explode; bind b kill"

alias disable "alias toggle enable;bind x voice_menu_2;bind 1 slot1; bind 2 slot2; bind 3 slot3; bind 4 slot4; bind 5 slot5; bind 6 slot6; unbind n; bind b dropitem"
1 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/genemilder Scripter Jul 11 '14

Your syntax seems correct, make sure you're actually running the changes. If it still doesn't work, recreate the script but with only a couple keys being changed. Once that works, scale it up so you can pinpoint the issue, if any.

1

u/Eternal_Nocturne Jul 12 '14

Alright, I did some testing. It appears you cannot set keys to voicemenu # without having " around them (like bind "x" "voicemenu 1 1"). I tested this by putting in bind voicemenu 0 0 which did not work, and bind "e" "voicemenu 0 0" which did. This makes me think the fact it starts off the command with a quotation mark (alias enable "alias ctoggle...) is somehow messing it up when it trys to bind keys.

I confirmed everything else works in with the echo and the explode command.

bind alt ctoggle

alias ctoggle "enable"

alias enable "alias ctoggle disable;bind e voicemenu 2 7;bind n explode;echo "alt mode active""


alias disable "alias ctoggle enable;bind "e" "voicemenu 0 0"; unbind "n";echo "alt mode unactive"

It still gives me the bind <key> [command]: attach a key to a command message, which means even though it's in there in theoretically the right place, it's not working.

1

u/genemilder Scripter Jul 12 '14 edited Jul 12 '14

You can definitely alias voicemenu commands when they're nested, meaning the following works:

alias enable "alias x_b voicemenu 1 1"

I don't use nested binds, so I guess it's possible that it doesn't work for bind statements.

That said, generally you never want to nest quotation marks, it can lead to unwanted behavior and it's not needed at all for this. Edit: If you want an example, see this script. No voicemenu commands but tons of nested aliases.

Separately, I always recommend against nested bind statements, instead advocating for binding the key to an alias whose definition is what is changed, not the top level bind.