From 75b1d4c4f2eac8168a186b348dde0cd7b3ea3983 Mon Sep 17 00:00:00 2001 From: fly Date: Tue, 10 Mar 2020 02:18:24 +0000 Subject: [PATCH] Add option to define saved props Signed-off-by: fly --- AircraftConfig/acconfig.nas | 4 ++-- Nasal/Systems/save.nas | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AircraftConfig/acconfig.nas b/AircraftConfig/acconfig.nas index 871a822c..5f875208 100644 --- a/AircraftConfig/acconfig.nas +++ b/AircraftConfig/acconfig.nas @@ -190,13 +190,13 @@ setlistener("/sim/signals/fdm-initialized", func { writeSettings(); if (getprop("options/system/save-state") == 1) { - save.restore(getprop("/sim/fg-home") ~ "/Export/" ~ getprop("/sim/aircraft") ~ "-save.xml"); + save.restore(save.default, getprop("/sim/fg-home") ~ "/Export/" ~ getprop("/sim/aircraft") ~ "-save.xml"); } spinning.stop(); }); setlistener("/sim/signals/exit", func { - save.save(getprop("/sim/fg-home") ~ "/Export/" ~ getprop("/sim/aircraft") ~ "-save.xml"); + save.save(save.default, getprop("/sim/fg-home") ~ "/Export/" ~ getprop("/sim/aircraft") ~ "-save.xml"); }); var renderingSettings = { diff --git a/Nasal/Systems/save.nas b/Nasal/Systems/save.nas index 04aefea8..f91cf4f2 100644 --- a/Nasal/Systems/save.nas +++ b/Nasal/Systems/save.nas @@ -16,8 +16,8 @@ # Save and restore properties between sessions -# To add more properties, just add them here: -var saved_props = [ +# To add more properties to autosave, just add them here. +var default = [ # CONSUMABLES # Fuel "/consumables/fuel/tank[0]/level-lbs", @@ -43,7 +43,7 @@ var saved_props = [ "/controls/gear/brake-parking" ]; -var save = func (file) { +var save = func (saved_props, file) { print("Saving state..."); for (var i = 0; i < size(saved_props); i += 1) { @@ -56,7 +56,7 @@ var save = func (file) { print("State saved"); } -var restore = func (file) { +var restore = func (saved_props, file) { print("Loading saved state..."); var readNode = props.globals.initNode("/save", );