Initializing Nasal early: Difference between revisions

Jump to navigation Jump to search
no edit summary
m (http://forum.flightgear.org/viewtopic.php?f=30&t=21083&p=214428#p214428)
No edit summary
Line 73: Line 73:
<syntaxhighlight lang="diff">
<syntaxhighlight lang="diff">
diff --git a/src/Main/options.cxx b/src/Main/options.cxx
diff --git a/src/Main/options.cxx b/src/Main/options.cxx
index 0389faa..f23a7ec 100644
index 0389faa..26eac9c 100644
--- a/src/Main/options.cxx
--- a/src/Main/options.cxx
+++ b/src/Main/options.cxx
+++ b/src/Main/options.cxx
Line 80: Line 80:
     } fgOptionArray[] = {
     } fgOptionArray[] = {
   
   
+    {"boot-script",           true,  OPTION_STRING, "/sim/startup/boot-script", false, "default.boot", 0 },
+    {"mode",         true,  OPTION_STRING, "/sim/startup/boot-script", false, "default", 0 },
     {"language",                    true,  OPTION_IGNORE, "", false, "", 0 },
     {"language",                    true,  OPTION_IGNORE, "", false, "", 0 },
-   {"console",                      false, OPTION_IGNORE,  "", false, "", 0 },
- {"console",                      false, OPTION_IGNORE,  "", false, "", 0 },
+    {"console",                      false, OPTION_IGNORE,  "", false, "", 0 },
+    {"console",                      false, OPTION_IGNORE,  "", false, "", 0 },
     {"disable-rembrandt",            false, OPTION_BOOL,  "/sim/rendering/rembrandt/enabled", false, "", 0 },
     {"disable-rembrandt",            false, OPTION_BOOL,  "/sim/rendering/rembrandt/enabled", false, "", 0 },
Line 88: Line 88:
     {"renderer",                    true,  OPTION_STRING, "/sim/rendering/rembrandt/renderer", false, "", 0 },
     {"renderer",                    true,  OPTION_STRING, "/sim/rendering/rembrandt/renderer", false, "", 0 },
diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx
diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx
index fde6319..c96ca90 100644
index fde6319..b8c2114 100644
--- a/src/Scripting/NasalSys.cxx
--- a/src/Scripting/NasalSys.cxx
+++ b/src/Scripting/NasalSys.cxx
+++ b/src/Scripting/NasalSys.cxx
Line 99: Line 99:
     simgear::Dir nasalDir(SGPath(globals->get_fg_root(), "Nasal"));
     simgear::Dir nasalDir(SGPath(globals->get_fg_root(), "Nasal"));
     loadScriptDirectory(nasalDir);
     loadScriptDirectory(nasalDir);
@@ -845,6 +846,18 @@ void FGNasalSys::init()
@@ -845,6 +846,20 @@ void FGNasalSys::init()
         simgear::PathList scripts = dir.children(simgear::Dir::TYPE_FILE, ".nas");
         simgear::PathList scripts = dir.children(simgear::Dir::TYPE_FILE, ".nas");
         addModule(directories[i].file(), scripts);
         addModule(directories[i].file(), scripts);
Line 105: Line 105:
+#endif
+#endif
+
+
+    const char* boot_script = fgGetString("/sim/startup/boot-script", "default.boot");
+    const char* boot_script = fgGetString("/sim/startup/boot-script", "default");
+    SGPath fullpath(globals->get_fg_root(), "Boot");
+    SGPath fullpath(globals->get_fg_root(), "Boot");
+    fullpath.append(boot_script);
+    fullpath.append(boot_script);
+    fullpath.concat(".boot");
+
+
+
+    SG_LOG(SG_NASAL, SG_INFO, "Using boot script:" << fullpath);
+    SG_LOG(SG_NASAL, SG_INFO, "Using boot script:" << fullpath);
+    SGPath file = fullpath.file();
+    SGPath file = fullpath.file();
+    if(!loadModule(fullpath, "boot")) {
+    if(!loadModule(fullpath, "boot")) {
+       SG_LOG(SG_NASAL, SG_ALERT, "Error could not load boot script:" << fullpath);
+   SG_LOG(SG_NASAL, SG_ALERT, "Error could not load boot script:" << fullpath);
+    exit(-1);
+    exit(-1);
+    }
+    }

Navigation menu