• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Coding temporary parts

Sorry it's been a while since you last advised me. I have though tried a few times to make temporary parts appear/disappear. This is how I got on:

FS9 (successful!!):

This block of text draws parts like chocks, intake covers, GPUs etc, while the AI aircraft is parked. As soon as the beacon light comes on, they disappear, ready for taxi out:

<part>
<name>parked_part</name>
<visible_in_range>
<parameter>
<code> (A:LIGHT BEACON, bool) (A:VELOCITY BODY Z, knots) 0 != || </code>
</parameter>
<minvalue>-1</minvalue>
<maxvalue>0</maxvalue>
</visible_in_range>
</part>

This block of code (when used with 0-100 key frame animation) positions an open canopy until the beacon light comes on, at which point the canopy closes:

<part>
<name>canopy_parked</name>
<animation>
<parameter>
<sim>
<variable>LIGHT BEACON</variable>
<units>bool</units>
<scale>100</scale>
</sim>
<lag>40</lag>
</parameter>
</animation>
</part>

In both cases, the Gmax part name, matches the name in the second line of each block of text. It works beautifully.

FSX (Failed):

I cannot however, get anywhere with FSX coding unfortunately. I tried the two suggested replacement blocks, but they had no effect. I don't know if AI aircraft don't recognise the engine rpm code. I would though like to tie the part to the beacon light, as I did for FS9, if that's possible.

To that end, I tried this in FSX:

<PartInfo>
<Name>parked_part</name>
<Visibility>
<Parameter>
<Code>
(A:LIGHT BEACON, bool) (A:VELOCITY BODY Z, knots) 0 != ||
</Code>
</Parameter>
</Visibility>
</PartInfo>

That didn't work either.

If someone would kindly answer these 3 questions please, I will hopefully progress further:

1. For the FS9 block of text that creates a parked_part, how do I turn the code the other way round, so that the part only appears after the beacon light has come on, eg for a pilot added to an empty cockpit?

2. Could someone please give me the two equivalent blocks of code that I have successfully used for FS9 for parked parts and canopy animation, tied to the beacon light, but for FSX please? If the reverse code for the pilot could also be included that would be terrific.

3. For FSX, do these blocks of code inform only the visibility tags or the animation tags (where animation is present) or do I need to tag both?

I'm really pleased with the FS9 result, but I would be a great help to crack it for FSX too.

Thanks so much, in anticipation.

John
 
Code:
    <PartInfo>
      <Name>parked_part</name>
      <Visibility>
        <Parameter>
          <Code>
            (A:LIGHT BEACON, bool) 1 != (A:VELOCITY BODY Z, knots) 1 &lt; and
            if{ 1 } els{ 0 }
          </Code>
        </Parameter>
      </Visibility>
    </PartInfo>

Try this.


1. Just invert the conditions.
(A:Light Beacon, bool) 1 == if{ 1 }

3. Animation tags are storen in the animation track of the object, while visibility tags are stored in an object's properties. So you can very well have an animated object with a visibility condition.
 
Bjoern,

Thank you for the new code. Please excuse me for not understanding xml coding. When I insert the block of text by copying and pasting it in modeldef.xml with Notepad, it looks properly indented like the previous entries. However when I open the file by double clicking it to open in IE9, it destroys the formatting of the file so that it becomes just a solid mass of text. What do I need to do to keep the integrity of the file please?

John
 
Opening the file in IE doesn't change the actual file on disk. Why are you opening in IE to begin with? It's completely unnecessary.
 
Because the exercise of adding the new block of code, rendered FSX GMax Attachpoint\visibility inoperative, I wasn't sure whether the added code itself was causing a problem, or I had somehow damaged the integrity of the modeldef.xml file. I opened the file in IE9 (double clicking it opens it that way) to check the latter. This is the sequence of events:

The unedited file looks like this in IE9 - all OK:

IE9_OK.jpg


The added block of code looks like this in Notepad - seems OK:

Notepad.jpg


The file now looks like this in IE9 - now all a single text block:

IE9_notOK.jpg


The Attach\Visibility tool loses all functionality after this message:

error_message.jpg


If I then remove the new block of code, everything returns to normal.

I managed to edit the FS9 file without a problem and the added code works well. FSX is proving far trickier. I made half the buildings in this Duxford scenery and 20 AI aircraft for both FS9 and FSX. I'd just love to be able to add pre-startup objects to the AI aircraft for future projects.

Crowd1.jpg


I'm OK with Gmax but .xml editing is driving me mad. What am I doing wrong please?
 
Don't use IE at all for XML. Notepad or Notepad2 (http://www.flos-freeware.ch/notepad2.html) totally suffices for displaying and editing XML.


My code would read as follows:

If the beacon light [ (A:LIGHT BEACON, bool) ] is off (= not [ != ] on [ 1 ] ) and [ and ] the velocity of the aircraft [ (A:VELOCITY BODY Z, knots) ] is less than 1 [ 1 &lt; ], then display the part [ if{ 1 } ], otherwise don't [ els{ 0 } ].
 
Oh my, the problem is simple, but difficult to spot.

Note the closing tag for <Name>...

</name>

Who'd a thunk that Capitalization could be so critical... :eek:

On the other hand, here's what my IE returns whenever it spots that error:

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

End tag 'name' does not match the start tag 'Name'. Error processing resource 'file:///E:/FSX_SDK/SDK/Environment Kit/Model...

<Name>parked_part</name>
-----------------------^


In any event, here's a simplified version that does work. Note that the if{ 1 } els{ 0 } isn't really necessary, as the entire function will evaluate as true (1) or false (0) without you needing to declare it:

Code:
  <PartInfo>
    <Name>parked_part</Name>
    <Visibility>
      <Parameter>
        <Code>
          (A:LIGHT BEACON,bool) !
          (A:VELOCITY BODY Z,knots) 1 &lt;
          and
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
 
Last edited:
You guys are just great. Thank you for sticking with me.

Bjoern, thank you for Notepad2. Bill, your block of code worked absolutely fine first time. I can't tell you how pleased I was to see my test cube disappear from a parked aircraft just as the engines started.

Would you stick with me a bit further please so that I can do the two other things I'd love to do:

1. Bill, what is the reverse of your code please, so that the temporary part displays only after the beacon light comes on, ie for a pilot sitting in the cockpit? Will the code line in the middle of the block also work for FS9?

2. What is the block of code, tied to the beacon light again, that will enable an animated canopy to remain open when the aircraft is parked, but close when the beacon light comes on please? That will obviously enable me to attach a visibility tag to the part, but will the same block of code also allow me to attach an animation tag, or is the latter not needed, or do I perhaps use a deafult door tag?

John
 
1. Bill, what is the reverse of your code please, so that the temporary part displays only after the beacon light comes on, ie for a pilot sitting in the cockpit? Will the code line in the middle of the block also work for FS9?

2. What is the block of code, tied to the beacon light again, that will enable an animated canopy to remain open when the aircraft is parked, but close when the beacon light comes on please? That will obviously enable me to attach a visibility tag to the part, but will the same block of code also allow me to attach an animation tag, or is the latter not needed, or do I perhaps use a deafult door tag?

John
1. There are two ways to "reverse" the conditions. One is to script the opposite conditions for the two variables. The other is to use the if{ x } els{ y } scheme.

Method #1:
Code:
  <PartInfo>
    <Name>parked_part</Name>
    <Visibility>
      <Parameter>
        <Code>
          (A:LIGHT BEACON,bool) 
          (A:VELOCITY BODY Z,knots) 0 &gt;
          and
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

Method #2:
Code:
  <PartInfo>
    <Name>unparked_part</Name>
    <Visibility>
      <Parameter>
        <Code>
          (A:LIGHT BEACON,bool) !
          (A:VELOCITY BODY Z,knots) 1 &lt;
          and
          if{ 0 } els{ 1 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

2. Here is the AI Canopy script I use:
Code:
  <PartInfo>
    <Name>T38_Canopy_AI</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>(A:LIGHT BEACON,bool) ! if{ 100 } els{ 0 }</Code>
        <Lag>10</Lag>
      </Parameter>
    </Animation>
  </PartInfo>

The script between the <Code> tags is the same for FS9 as for FSX. Note that the "Canopy_AI" script does not use any "door" variables at all. It is strictly condition driven, and uses the <Lag> entry to slow down the animation. Smaller numbers are slower movement. The number is the frames per second, so a <Lag> of 10 means roughly 10 seconds from open to closed, and vice-versa.
 
Last edited:
Bill, you are a gem. That's exactly what I have been looking for. It's a bit late here to test out now, but I will have a good go first thing in the morning when I am fresher and I'll report back. Thank you so much.

John
 
Played with the code for a while this morning Bill. Success with the "unparked_part" code for FSX. Thank you for that.

4 down 2 to go:

In FS9, I can't get the same "unparked_part" code to work in the sim:

FS9.jpg


In your method 1 below, is there something missing after "and" in the code please?

In FSX, it's now only the canopy part that I can't get to work. It's not actually listed in the visibility drop down menu of the attachpoint tool:

FSX.jpg


Should there be something about visibility in the entry?

Feels so close, but not quite there.

John
 
FS9: change these to...
<minvalue>0</minvalue>
<maxvalue>1</maxvalue>
...as the "visible" value is 1.

The FSX canopy isn't a "visible" condition at all! It is an "animation." You will need to keyframe animate the canopy, then use the Animation Manager to apply the script to the canopy.
 
Still no luck Bill. Changed the FS9 min/max values as you suggested but my test cube continues to appear before and after startup.

I had already applied the 0-100 keyframes to the FSX canopy and was expecting to have to apply an animation tag as you suggest. The problem for me is that my custom "Canopy_AI" does not appear in the FSTools\animation manager or the Attachpoint roll-outs, so I can't actually apply the required tag.

I don't want to continue taking up your time needlessly, but I really think I could make good use of these scipts if I could get the final 2 to work. If I were to post the two .xml files, which are the default files plus the 3 custom blocks in each, would you have the time to just run your eye over them please?
 
If you can't see the "Canopy_AI" in the Animation Tool, then you probably didn't create the <Animation...guid=xxx.../> entry...

Code:
<Animation name="Canopy_AI" guid="929f3960-538c-409e-901c-02cc2b2dbda2" length="100" type="Sim" typeParam2="Canopy_AI" typeParam="AutoPlay" />

Yes, if you post your scripts I would be happy to take a squint at 'em! :cool:
 
Thanks Bill, that was indeed the missing ingredient. Having added in that line, the canopy works fine. Thank you.

5 down, 1 to go!

The FS9 "unparked_part", eg for a pilot that appears in the cockpit after the beacon comes on, just displays all the time at the moment. I have attached my makemdl.parts.xml to see if you can spot the error. It's the last entry at the bottom of the page.

The converse "parked_part", eg for an intake cover or ground power unit works fine.
 

Attachments

Now that you've explained just what you want to occur (show pilot when beacon light is on), the script becomes simpler!

Code:
  <part>
    <name>unparked_part</name>
    <visible_in_range>
      <parameter>
        <code>
          (A:LIGHT BEACON,bool)
        </code>
      </parameter>
      <minvalue>1</minvalue>
    </visible_in_range>
  </part>

Of course, it might make sense to rename the <name> entry to:

<name>show_AI_pilot</name> just for clarity of intended purpose... :D

Note that in FS9 XML schema, to invert the action of any script one need only change the <minvalue> and <maxvalue> entries. Here for example is script to have two "sealed beam" lights; one unlighted and the other lighted:

Code:
  <part>
    <Name>CJ1recog_light_left_off</Name>
    <visible_in_range>
      <parameter>
        <Code>(L:RecogLight_Left, number)</Code>
      </parameter>
      <minvalue>-1</minvalue>
      <maxvalue>0</maxvalue>
    </visible_in_range>
  </part>

  <part>
    <Name>CJ1recog_light_right_on</Name>
    <visible_in_range>
      <parameter>
        <Code>(L:RecogLight_Right, number)</Code>
      </parameter>
      <minvalue>1</minvalue>
    </visible_in_range>
  </part>

What's of interest in the above is that we must always have a <minvalue> entry, but <maxvalue> is only needed under certain circumstances, such as when we need something to appear only when a value is zero, or perhaps only within a range of values.

Alternatively, I could have used the same script as the _on version, and reversed the action by simply negating the <code> condition:

<Code>(L:RecogLight_Left, number) !</Code>
 
Last edited:
Brilliant, the pilot appearing on start-up of the beacon light has worked. Success on all 6 scripts!

Although I have been building scenery for more than 15 years, I have only ventured into AI aircraft for the past year. It's been a really enjoyable learning experience and with those 6 new scripts Bill, you have enabled me to go one step further with the ability to set up parked and non-parked parts for both FS9 and FSX AI aircraft.

Thank you so much for your patience and for getting me to my goal. I will be making much use of the facility and I'm really grateful for your help.

Best regards,

John
 
Thank you so much for your patience and for getting me to my goal. I will be making much use of the facility and I'm really grateful for your help.

You are most very welcome, John! All I ask is that you pass it along to anyone else who needs such help. After all, as much as I may regret it, I won't be around forever... ;)
 
Yes indeed Bill and to that end, I have put together a short tutorial on what the 6 scripts achieve and how to set them up. I have done that as a Notepad text file so the scripts can be easily copied and pasted. That will be handy for anyone contacting me after publishing some work that uses them. It will also save users on this forum, ploughing through the development history of the scripts in this topic to get to the final working 6.
 

Attachments

Last edited:
Back
Top