wlbragg wrote in Wed Feb 07, 2018 3:48 pm:Something like this
Fantastic! Thank you so much for your gracious assistance, wlbragg
I've created the nasal script as you've suggested and, I've modified my xml file to include the variable "terrain_elev" in place of the previously-hard coded 'altitude' value. It's painfully obvious that I'm still missing something because the only time that I was able to see the ship was when I put my UFO into "submarine mode" and dove to 0' Sea Level. I'm certain that I need something else to indicate that "terrain_elev" is called by the nasal file. Could I push my luck and ask you how this must be done? And, one more thing (yeah, I'm really pushing my luck now...): How did you display the script log on your screen? This would be great for trying to muddle my way through a de-bugging case.
Here is my xml file:
- Code: Select all
<?xml version="1.0"?>
<PropertyList>
<!-- enhansed Braunschweig-class corvette AI ship V1.0 -->
<scenario>
<name>FGS_Braunshweig_hevii</name>
<description>
Places a Braunschweig-class corvette (K130) environment -
Notes:
TACAN-channel-ID Defines a TACAN channel for display
purposes only
</description>
<entry>
<type>carrier</type>
<name>FGS_Braunshweig</name>
<pennant-number>F260</pennant-number>
<model>Models/Geometry/K130/F260.xml</model>
<TACAN-channel-ID>026x</TACAN-channel-ID>
<!-- Edit the following for initial start position, heading + speed -->
<!-- Adriatic Sea> -->
<!--
<latitude>45.066</latitude>
<longitude>-12.980</longitude>
<speed>10</speed>
<heading>125</heading>
-->
<!-- Bodensee -->
<latitude>47.5149611</latitude>
<longitude>9.6563101</longitude>
<altitude>terrain_elev</altitude>
<speed>10</speed>
<heading>290</heading>
<!--Lake Ontario -->
<!--
<latitude>44.181</latitude>
<longitude>-76.566</longitude>
<altitude>156</altitude>
<speed>10</speed>
<heading>200</heading>
-->
<!-- St Lawrence Seaway (Québec) -->
<!--
<latitude>47.187</latitude>
<longitude>-70.434</longitude>
<altitude>17</altitude>
<speed>10</speed>
<heading>28</heading>
-->
<parking-pos>
<name>Heli1</name>
<heading-offset-deg>0</heading-offset-deg>
<x-offset-m>90.0</x-offset-m>
<y-offset-m>0</y-offset-m>
<z-offset-m>4</z-offset-m>
</parking-pos>-->
</entry>
</scenario>
</PropertyList>
And this is my copy of your nasal code (saved as live_surface_elev.nas):
- Code: Select all
setlistener("/sim/signals/fdm-initialized", func {
#this needs to match what is designated in the XML
var ship = "FGS_Braunshweig _hevii";
foreach(var shipN; props.globals.getNode("/ai/models", 1).getChildren("aircraft")) {
{
if (string.match(shipN.getNode("callsign").getValue(), ship")) {
aiParent = shipN.getNode("callsign").getParent().getName() ~ "[" ~ shipN.getNode("callsign").getParent().getIndex() ~ "]";
var currentLat = props.globals.getNode("/ai/models/" ~ aiParent ~ "/latitude-deg").getValue();
var currentLon = props.globals.getNode("/ai/models/" ~ aiParent ~ "/longitude-deg").getValue();
var terrain_elev = geo.elevation(currentLat, currentLon);
props.globals.getNode("ai/models/" ~ aiParent ~ "/altitude-ft").setDoubleValue(terrain_elev);
}
}
});