Here I've got one tank script with turning, done for another user (murkz), it may be helpful for you:
//vehicle script file
//see http://xtrac.outerra.com/index.fcgi/wiki/vehicle for example and documentation
//invoked only the first time the model is loaded, or upon reload
function init_chassis(){
var wheelparam = {
radius: 0.46,
width: 0.20,
suspension_max: 0.2,
suspension_min: -0.35,
//ride height
suspension_stiffness: 3.0,
damping_compression: 0.2,
damping_relaxation: 0.12,
slip: 0.5,
roll_influence: 0.1
//rotation: -1
};
this.add_wheel('wheel1', wheelparam);
this.add_wheel('wheel2', wheelparam);
this.add_wheel('wheel3', wheelparam);
this.add_wheel('wheel4', wheelparam);
this.add_wheel('wheel5', wheelparam);
this.add_wheel('wheel6', wheelparam);
this.add_wheel('wheel7', wheelparam);
this.add_wheel('wheel8', wheelparam);
this.add_wheel('wheel9', wheelparam);
this.add_wheel('wheel10', wheelparam);
this.add_wheel('wheel11', wheelparam);
this.add_wheel('wheel12', wheelparam);
this.add_wheel('wheel13', wheelparam);
this.add_wheel('wheel14', wheelparam);
this.add_wheel('wheel15', wheelparam);
this.add_wheel('wheel16', wheelparam);
return {mass:7530, steering:2.0, steering_ecf:60, centering: 10, centering_ecf:20};
}
//invoked for each new instance of the vehicle
function init_vehicle(){
this.set_fps_camera_pos({x:-0.33,y:2.00,z:2.10});
}
//invoked when engine starts or stops
function engine(start){
}
const EF = 10000.0;
const BF = 4000.0;
const maxkmh = 50;
const forceloss = EF / (0.2*maxkmh + 1);
//invoked each frame to handle the inputs and animate the model
function update_frame(dt, engine, brake, steering){
var kmh = this.speed()*3.6;
//reduce engine force with speed (hack)
var redux = engine>=0 ? 0.2 : 0.6;
var esign = engine<0 ? -1 : 1;
engine = EF*Math.abs(engine);
var force = (esign>0) == (kmh>=0)
? engine/(redux*Math.abs(kmh) + 1)
: engine;
force -= forceloss;
force = Math.max(0.0, Math.min(force, engine));
engine = esign*force;
var el = steering>0 ? 0 : engine;
var er = steering<0 ? 0 : engine;
this.wheel_force(0, el);
this.wheel_force(2, el);
this.wheel_force(4, el);
this.wheel_force(6, el);
this.wheel_force(8, el);
this.wheel_force(10, el);
this.wheel_force(12, el);
this.wheel_force(14, el);
this.wheel_force(1, er);
this.wheel_force(3, er);
this.wheel_force(5, er);
this.wheel_force(7, er);
this.wheel_force(9, er);
this.wheel_force(11, er);
this.wheel_force(13, er);
this.wheel_force(15, er);
brake *= BF;
var bl = steering>0 ? BF*steering : 0;
var br = steering<0 ? -BF*steering : 0;
bl += brake;
br += brake;
this.wheel_brake(0, bl);
this.wheel_brake(2, bl);
this.wheel_brake(4, bl);
this.wheel_brake(6, bl);
this.wheel_brake(8, bl);
this.wheel_brake(10, bl);
this.wheel_brake(12, bl);
this.wheel_brake(14, bl);
this.wheel_brake(1, br);
this.wheel_brake(3, br);
this.wheel_brake(5, br);
this.wheel_brake(7, br);
this.wheel_brake(9, br);
this.wheel_brake(11, br);
this.wheel_brake(13, br);
this.wheel_brake(15, br);
this.animate_wheels();
}