1
0
Fork 0

export flightplan on 'n'-key

This commit is contained in:
mfranz 2007-10-18 21:20:39 +00:00
parent eb5b350ec9
commit 33805eaa58
2 changed files with 35 additions and 0 deletions

View file

@ -87,6 +87,10 @@
<name>m</name>
<desc>toggle marker for active (= last selected) object</desc>
</key>
<key>
<name>n</name>
<desc>export flightplan</desc>
</key>
<key>
<name>P</name>
<desc>toggle radar panel (see Ctrl-C for the control areas)</desc>
@ -181,6 +185,15 @@
</binding>
</key>
<key n="110">
<name>n</name>
<desc>Export FlightPlan</desc>
<binding>
<command>nasal</command>
<script>ufo.export_flightplan()</script>
</binding>
</key>
<key n="360">
<name>PageUp</name>
<desc>Increase throttle or autopilot autothrottle.</desc>
@ -374,6 +387,7 @@
<switch type="string" archive="y">on</switch>
<range type="double" archive="y">40</range>
<mode-control type="int" archive="y">2</mode-control>
<limit-deg type="double">180</limit-deg>
<mode type="string" archive="y">WX</mode>
<lightning type="bool" archive="y">true</lightning>

View file

@ -633,6 +633,27 @@ var export_data = func {
}
var export_flightplan = func {
var path = getprop("/sim/fg-home") ~ "/ufo-flightplan-export.xml";
var args = props.Node.new({ filename : path });
var export = args.getNode("data/flightplan", 1);
var waypoints = modelmgr.get_data().getChildren("model");
forindex (var i; waypoints) {
var from = waypoints[i];
var to = export.getChild("wpt", i, 1);
to.getNode("name", 1).setValue("#" ~ i);
to.getNode("lat", 1).setDoubleValue(from.getNode("latitude-deg").getValue());
to.getNode("lon", 1).setDoubleValue(from.getNode("longitude-deg").getValue());
to.getNode("crossat", 1).setDoubleValue(from.getNode("elevation-ft").getValue());
to.getNode("on-ground", 1).setBoolValue(1);
to.getNode("ktas", 1).setDoubleValue(100);
}
export.getChild("wpt", i, 1).getNode("name", 1).setValue("END");
fgcommand("savexml", args);
print("flightplan exported to ", path);
}
var file_selector = nil;