1
0
Fork 0

Saving works now!

This commit is contained in:
legoboyvdlp R 2020-05-18 00:11:24 +01:00
parent 82631ed689
commit f01fc6bc6a

View file

@ -100,24 +100,20 @@ var WaypointDatabase = {
write: func() { write: func() {
var path = getprop("/sim/fg-home") ~ "/Export/savedWaypoints.xml"; var path = getprop("/sim/fg-home") ~ "/Export/savedWaypoints.xml";
var tree = { var tree = {
"waypoints": { waypoints: {
}, },
}; };
var node = props.Node.new(tree);
for (var i = 0; i < me.getSize(); i = i + 1) { for (var i = 0; i < me.getSize(); i = i + 1) {
if (me.waypointsVec[i] != nil) { if (me.waypointsVec[i] != nil) {
node.getChild("waypoints").addChild(me.waypointsVec[i].tree); tree.waypoints["waypoint" ~ i] = me.waypointsVec[i].tree;
debug.dump(me.waypointsVec[i].tree);
} else { } else {
node.getChild("waypoints").addChild(nilTree); tree.waypoints["waypoint" ~ i] = nilTree;
} }
} }
debug.dump(node);
io.writexml(path, node); # write the data io.writexml(path, props.Node.new(tree)); # write the data
}, },
}; };
@ -142,11 +138,9 @@ var pilotWaypoint = {
pilotWp.wpGhost = createWP(positioned, pilotWp.id); pilotWp.wpGhost = createWP(positioned, pilotWp.id);
pilotWp.tree = { pilotWp.tree = {
"waypoint": { "latitude": pilotWp.wpGhost.wp_lat,
"latitude": pilotWp.wpGhost.wp_lat, "longitude": pilotWp.wpGhost.wp_lon,
"longitude": pilotWp.wpGhost.wp_lon, "ident": pilotWp.id,
"ident": pilotWp.id,
},
}; };
return pilotWp; return pilotWp;