Simple If Then Else Scripting in TF2

Not only Team Fortress 2, all Half-Life 2 games actually. Yeap, it's easy. A friend of mine asked me something like this

  • I want to make the "g" key make the fov 90 on a press and 75 on the other press. It should toggle.

The code is like this;

alias ws1 "fov_desired 75; bind g ws2"  
alias ws2 "fov_desired 90; bind g ws1"  
bind g ws1  


I hope it works for you.

Here is the explanation:

  • As far as I know, there is no if then else logic on that platform. There is only bindings or aliases for the time being. So the algorithm is a bit more complicated, like calling functions with a global variable.

So, the flow of the above script is below;

# this is not a tf2 script, just pseudo code.

method1 {  
  fov=90;
  on keypress g: call method2;
}

method2 {  
  fov=130;
  on keypress g: call method1;
}

on keypress g: call method1;

# this is not a tf2 script, just pseudo code.

Comments

comments powered by Disqus