EDIT: I finally got around to rewriting this script, it is acually readable and more usable.
EDIT2: Emulated default scroll wheel item switching, and added view model aliases for ease of use.
alias view1 "slot1; r_drawviewmodel 1"
alias view2 "slot2; r_drawviewmodel 1"
alias view3 "slot3; r_drawviewmodel 1"
bind MWHEELUP "prevslot"
bind MWHEELDOWN "nextslot"
bind q "lastslot"
bind 1 @slot1
bind 2 @slot2
bind 3 @slot3
alias push0 ""
alias push1 ""
alias @slot1 "view1; push0; push1; alias push0 stack1; alias nextslot @slot2; alias prevslot @slot3"
alias @slot2 "view2; push0; push1; alias push0 stack2; alias nextslot @slot3; alias prevslot @slot1"
alias @slot3 "view3; push0; push1; alias push0 stack3; alias nextslot @slot1; alias prevslot @slot2"
alias stack1 "alias push1 pop1"
alias stack2 "alias push1 pop2"
alias stack3 "alias push1 pop3"
alias pop1 "alias lastslot @slot1"
alias pop2 "alias lastslot @slot2"
alias pop3 "alias lastslot @slot3"
OLD POST:
So I have had a minor annoyance with scriping in TF2, namely there is no way to do weapon based setting in all cases, like when using the lastinv command. While this can be worked around, if you want to do +- weapon binds, you are forced to use lastinv. I just recently came upon the solution to that problem, a implementation of lastinv, done competely in aliases.
All credit goes to MrRadicalEd of the Natural Selection forum.
//to use, use "lastslot" where you would otherwise use "lastinv", and @slot# where you would otherwise use slot#
alias null ""
alias sswitch ""
alias !lastslot ""
alias ?lastslot ""
//
alias @slot1 "slot1;!slot1.same;?lastslot;!lastslot;alias ?lastslot is.slot1;alias !same.slot !slot1.same+;alias !slot1.same !same.slot;"
alias is.slot1 "alias !lastslot !slot1;alias !slot1.same sswitch"
alias !slot1 "alias lastslot @slot1"
alias !slot1.same+ "alias ?lastslot null;alias sswitch !slot1.sswitch"
alias !slot1.sswitch "alias !slot1.same sswitch"
alias !slot1.same "sswitch"
alias @slot2 "slot2;!slot2.same;?lastslot;!lastslot;alias ?lastslot is.slot2;alias !same.slot !slot2.same+;alias !slot2.same !same.slot;"
alias is.slot2 "alias !lastslot !slot2;alias !slot2.same sswitch"
alias !slot2 "alias lastslot @slot2"
alias !slot2.same+ "alias ?lastslot null;alias sswitch !slot2.sswitch"
alias !slot2.sswitch "alias !slot2.same sswitch"
alias !slot2.same "sswitch"
alias @slot3 "slot3;!slot3.same;?lastslot;!lastslot;alias ?lastslot is.slot3;alias !same.slot !slot3.same+;alias !slot3.same !same.slot;"
alias is.slot3 "alias !lastslot !slot3;alias !slot3.same sswitch"
alias !slot3 "alias lastslot @slot3"
alias !slot3.same+ "alias ?lastslot null;alias sswitch !slot3.sswitch"
alias !slot3.sswitch "alias !slot3.same sswitch"
alias !slot3.same "sswitch"