I was going to just send this to Andy, but I figured why bug him, maybe
someone else knows the answer, so ...

OK, I'm having trouble figuring out how to do this. Here's what I have.
First, there is this property tree set up:

 <yasim>
   <weights>
      <bomb-bay>
       <rack n="0" type="double">0</rack>
       <rack n="1" type="double">0</rack>
       <rack n="2" type="double">0</rack>
       <rack n="3" type="double">0</rack>
       <rack n="4" type="double">0</rack>
       <rack n="5" type="double">0</rack>
       <rack n="6" type="double">0</rack>
       <rack n="7" type="double">0</rack>
     </bomb-bay>
   </weights>
 </yasim>

You can guess what that is for.

Now, I also have a set of databases set up in the property tree
describing various bomb load configurations:

<loadout n="1">
   <name archive="y">8 M-17 500 lb. magnesium incendiary cluster
bombs</name>
   <interleave-sec type="double" archive="y">4</interleave-sec>
   <bomb n="0">
      <!--M17.001-->
      <weight type="int">500</weight>
      <dropped type="bool">false</dropped>
      <rack>8</rack>
   </bomb>
   <bomb n="1">
      <!--M17.002-->
      <weight type="int">500</weight>
      <dropped type="bool">false</dropped>
      <rack>1</rack>
   </bomb>
//SNIP//   <bomb n="7">
      <!--M17.008-->
      <weight type="int">500</weight>
      <dropped type="bool">false</dropped>
      <rack>3</rack>
   </bomb>
</loadout>

There are multiple loadouts.

I also have a nasal function that gets called when someone switches to a
prticular configuration via a listener:

loadBombs = func {
   # Find out which bomb configuration we are now using.
   loadout_index =  getprop('/sim/weapons/current-loadout');

   # Delete any YASim weights.
   weights = props.globals.getNode('/yasim/weights/bomb-bay');
   racks = weights.getChildren();
   foreach (rack, racks) {
      rack.setDoubleValue(0);
   }

   # Set all the bomb triggers, and assign the proper weights for YASim.
   loadout =
props.globals.getNode('/sim/weapons/loadout['~$loadout_index~']');
   bombs = loadout.getChildren();
   foreach (bomb, bombs) {
      dropped =  bomb.getNode(dropped);
      dropped.setBoolValue(false);
      # A MIRACLE OCCURS
   }

}

My problem is that I need to replace the miracle with some code. I want
to reference a property node /yasim/weights/bomb-bay/rack[n] based on
/sim/weapons/loadout[]/bomb[]/rack, which is an integer (even though I
have not specifically typed it yet in the xml file). That way I will be
able to add the appropriate weight for that particular bomb to the
correct bomb rack. This will allow realistic trim changes!

Is there an easy way to do this that I don't know about?

Josh


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to