Outerra forum
Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => JavaScript development => Topic started by: bomber on April 21, 2015, 02:38:48 pm
-
Hi, I'd like to create a simple wingleveler autopilot, but need to be able to enable/disable...
I want to extend the view commands such that I have a duplicate pilot view, but jumping to that view changes a jsbsim property to '1' and not being in that view set the property to '0'
can someone mod the code below so as I can paste it into the .js file..
regards
Simon
//Camera positions + ground effect
var camera_z = clamp((this.fdm["gear/unit[0]/compression-ft"]+this.fdm["gear/unit[1]/compression-ft"]+this.fdm["gear/unit[2]/compression-ft"])*this.fdm["gear/unit[0]/compression-ft"]*0.2, -0.05, 0.05);
if(seat_cam===0)
this.set_fps_camera_pos({x:-0.25, y:-0.2, z:0.3-camera_z}); //Front Seat Left
else if(seat_cam===1)
this.set_fps_camera_pos({x: 0.25, y:-0.2, z:0.3-camera_z}); //Front Seat Right
else if(seat_cam===2)
this.set_fps_camera_pos({x:-0.25, y:-1, z:0.2-camera_z}); //Back Seat Left
else if(seat_cam===3)
this.set_fps_camera_pos({x: 0.25, y:-1, z:0.2-camera_z}); //Back Seat Right
else if(seat_cam===4)
this.set_fps_camera_pos({x:0.0,y: 1.0,z: 0.2}); //Nose
else if(seat_cam===5)
this.set_fps_camera_pos({x:-0.6,y:-1.5,z:-0.2}); //Body Left
else if(seat_cam===6)
this.set_fps_camera_pos({x: 0.6,y:-1.5,z:-0.2}); //Body Right
else if(seat_cam===7)
this.set_fps_camera_pos({x:-4.2,y:-0.1,z: 0.3}); //Wing Left
else if(seat_cam===8)
this.set_fps_camera_pos({x: 4.2,y:-0.1,z: 0.3}); //Wing Right
else if(seat_cam===9)
this.set_fps_camera_pos({x: 0,y:-5.1,z: 1.2}); //Tail
-
This should work. Just edit this property, this.fdm["fcs/wing_lvl_ap"]=wing_lvl_ap; to the one you are trying to set.
Regards,
Uriah
//Camera position + ground effect + Wing Level AP Switch
var wing_lvl_ap;
this.fdm["fcs/wing_lvl_ap"]=wing_lvl_ap;
var camera_z = clamp((this.fdm["gear/unit[0]/compression-ft"]+this.fdm["gear/unit[1]/compression-ft"]+this.fdm["gear/unit[2]/compression-ft"])*this.fdm["gear/unit[0]/compression-ft"]*0.2, -0.05, 0.05);
if(seat_cam===0)
this.set_fps_camera_pos({x:-0.25, y:-0.2, z:0.3-camera_z}); //Front Seat Left
if(seat_cam===1)
this.set_fps_camera_pos({x:-0.25, y:-0.2, z:0.3-camera_z}); //Front Seat Left
if(seat_cam===0){wing_lvl_ap=0;} //Turn OFF Wing Level Autopilot
if(seat_cam===1){wing_lvl_ap=1;} // Turn ON Wing Level Autopilot
-
Cheers, will look at it and the fuel system...
-
Whooops. Just noticed a mistake, and realized you'll need another function modified, so instead here is the full script:
http://www.mediafire.com/view/n6o95o2gw3vw2wm/c172.js
I removed all of the camera positions except 0 and 1, so now it works as you requested.
I also added a function to display the state of Wing Level AP in the debug console, (P key).
var seat_cam = 0;
function switch_seat(cam){
if(cam===0) seat_cam=0;
else if(cam===1)seat_cam=1;
else return false;return true;}
//Camera position + ground effect + Wing Level AP Switch
var wing_lvl_ap;
this.fdm["fcs/wing_lvl_ap"]=wing_lvl_ap;
var camera_z = clamp((this.fdm["gear/unit[0]/compression-ft"]+this.fdm["gear/unit[1]/compression-ft"]+this.fdm["gear/unit[2]/compression-ft"])*this.fdm["gear/unit[0]/compression-ft"]*0.2, -0.05, 0.05);
if(seat_cam===0)
this.set_fps_camera_pos({x:-0.25, y:-0.2, z:0.3-camera_z}); //Front Seat Left
if(seat_cam===1)
this.set_fps_camera_pos({x:-0.25, y:-0.2, z:0.3-camera_z}); //Front Seat Left
if(seat_cam===0){wing_lvl_ap=0;} //Turn OFF Wing Level Autopilot
if(seat_cam===1){wing_lvl_ap=1;} // Turn ON Wing Level Autopilot
-
P.S. If you are using a newer version of Levi's C172 script with additional functions, e-mail it to me and I'll integrate the changes.
-
Ok what key do I press for jumping seats ?
-
V key.
-
also the log (P key) is that intended, wouldn't it be better if it only logged everytime the AP was turned on or off.... ie change of state ?
-
I just added that so you could see what camera mode you are in. There isn't a way I can think of to log that only at the time when you change seats, as I have to call it from the update section. If you want to remove it, comment out the line at the very bottom of the script. Also, you'll notice that when you hit C key to go to external view, and then return to cockpit view with V key, that the camera mode will return to the default seat_cam = 0; I could write a logic function to keep the prior seat_cam mode so it doesn't default to 0. Of course the extended controls will have a key bind specifically for turning on/off autopilot.
Regards,
Uriah
-
Oh there's no need to throw good time into this it's just a proof of Auto-pilot concept...
AND IT WORKS :)
-
Nice!!! 8)
-
"I also added a function to display the state of Wing Level AP in the debug console, (P key)."
Did we lose the debug console in a release ?
-
Moved to Alt+L, and Alt+Shift+L opens a separate log window.
-
Thanks