• 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.

FSXA Visibility condition in AI model

Messages
130
Country
unitedkingdom
Hi

I'm trying to get rid of a few objects after converting with MCX (like parking blocks, fan covers, auxiliary power... those sort of things). I mean make them invisible when they are not relevant, and visible when parked.

So far I had success assigning light_batteryOFF or light_bacon. However using these only make the objects disappear after the pushback, meaning that the unrealistic effect of the objects being dragged during pushback remains.

In an attempt to avoid the pushback problem I tried using the following:

Code:
  <PartInfo>
    <Name>blocks_vis</Name>
    <Visibility>
      <Parameter>
        <Code>
      (A:PUSHBACK WAIT, bool)
      (A:ELECTRICAL MASTER BATTERY, bool)
      and
    </Code>
      </Parameter>

but it didn't do anything.

I though about using BRAKE PARKING INDICATOR but being useless with code I don't know how to write "Position (0 to 32K) 0 = off, 32K full"

I wonder if someone could help me on this. Please note that I do not have any expertise with code, I do the micro tiny bit I do looking at what is written in other modeldef.xml and on the internet

Cheers
 
I think AI aircraft turn on their nav lights before they push back, so you might just want to use that variable.

For parking brakes, you can also use (A:BRAKE PARKING POSITION, percent).
"Position" kind of variables can use a value range of 0.0 to 1.0.
 
I'd say you can only use A:vars which are multiplayer compatible.

Refer to the Simulation Variables table in the SDK.

All the light settings are transmitted over multiplayer but pushback state is not.

Have you tried AI TRAFFIC STATE ?

Code:
(A:AI TRAFFIC STATE,string) 'push back 1' scmp 0 ==
if{
    <!-- In push back 1 state do something -->
}

Or I think this should cover the conditions where you would want those items visible (note the five or conditions at the end || || || || || )
Code:
(A:AI TRAFFIC STATE,string) 'sleep' scmp 0 ==
(A:AI TRAFFIC STATE,string) 'flt plan' scmp 0 ==
(A:AI TRAFFIC STATE,string) 'startup' scmp 0 ==
(A:AI TRAFFIC STATE,string) 'preflight support' scmp 0 ==
(A:AI TRAFFIC STATE,string) 'clearance' scmp 0 ==
(A:AI TRAFFIC STATE,string) 'postflight support' scmp 0 == || || || || ||
if{
    <!-- Code to show items -->
    1
}
 
Last edited:
Thank you both for the answers. I've tried Heretic's suggestion with no success. The last I've tried is
Code:
(A:AI TRAFFIC STATE,string) 'clearance' scmp 0 == if{ 0 } els{ 1 }
but is not working, the blocks remain all the time visible. If I change the order
Code:
(A:AI TRAFFIC STATE,string) 'clearance' scmp 0 == if{ 1 } els{01 }
they simply disappear all together, never show up

I don't know... but I have to stress, my knowledge about code and programing is almost null. Not sure whether I am too ambitious.

I really appreciate your help and patience anyway

Cheers
 
For intake covers, etc...the only valid traffic states are "sleep" and "flt plan", so...

Code:
(A:AI TRAFFIC STATE,string) 'sleep' scmp 0 ==
(A:AI TRAFFIC STATE,string) 'flt plan' scmp 0 == or
if{ 1 } els{ 0 }
 
Bjoern

Thank you. I'll give it a go in a minute.
Could I take the chance and try to learn something about xml here (as I said and useless, I'm just a vet...) Is that code actually saying that the parts related (covers, block.. that stuff) should be visible if at sleep or flt plan (and for that the value 1) otherwise they won't hence the value 0?

I'll report back

Cheers
 
this is how I wrote it in my modeldef.xml file:

HTML:
  <PartInfo>
    <Name>blocks_vis</Name>
    <Visibility>
      <Parameter>
        <Code>
          (A:AI TRAFFIC STATE,string) 'sleep' scmp 0 ==
          (A:AI TRAFFIC STATE,string) 'flt plan' scmp 0 == or
          if{ 1 } els{ 0 }
    </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

... and it simply never show up, nor when asleep neither when push back or taxing...
 
Have you tried evaluating for (A:LIGHT BEACON, bool)?

Then again, I faintly seem to recall ageneral problem with FSX AI and conditional animations. Might be worth seraching the forums?

In your code block, the string "A:AI TRAFFIC STATE" is evaluated against "sleep" and against "flt plan". If there is no difference between the string and "sleep" ("scmp" - compare string; "0 ==" - no difference) or between the string and "flt plan", the evaluation is positive and thus the "if{ }" state is selected. If "A:AI TRAFFIC STATE" contains neither "sleep" nor "flt plan", the evaluation is negative and the "els{ }" state is selected. The "1" and "0" ultimately tells FSX' rendering engine to display the part or not to display the part.

The "if{ 1 } els{ 0 }" is actually only present to keep you sane. Without it, the code will evaluate to the same result.
Code:
<PartInfo>
<Name>blocks_vis</Name>
<Visibility>
<Parameter>
<Code>
(A:AI TRAFFIC STATE,string) 'sleep' scmp 0 ==
(A:AI TRAFFIC STATE,string) 'flt plan' scmp 0 == or
</Code>
</Parameter>
</Visibility>
</PartInfo>
 
Bjoern

A big thank you, massively educating for me. At least I understand now what I was trying to write.

Yes, I use light beacon (actually I have one block with this visibility and I test with the other block). Light Beacon works in terms of making it disappear, but only does it after pushback, that is why I'm looking for an alternative to avoid the unrealistic effect of the blocks being dragged during the pushback. But other than that, it works. Below is the code, but this one I think is quite straight forward, I probably have copied it from other similar visibility conditions in the modeldef.xml:

Code:
  <PartInfo>
    <Name>light_beacon_vis</Name>
    <Visibility>
      <Parameter>
        <Code>
      (A:LIGHT BEACON,bool) 1 == if{ 0 } els{ 1 }
    </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

Cheers
 
Well, your question finally prompted me to investigate that seemingly counterintuitive "scmp 0 ==" statement, so we both learned something here.

There's also a ground velocity variable ( (A:GROUND SPEED,knots), I think). What happens if you add it to the beacon light condition (with (A:GROUND SPEED,knots) 0 != ) ?
If FSX does track this variable for AI aircraft, the chocks should disappear as soon as the plane is moving and stay invisible as soon as it switches on its beacon light.
 
Something like this? (although there should be something wrong because it is not showing up in the visibility condition menu whithin the hierarchy editor)

Code:
  <PartInfo>
    <Name>custom_light_beacon_vis_mine</Name>
    <Visibility>
      <Parameter>
        <Code>
      (A:LIGHT BEACON,bool) 1 == && (A:GROUND VELOCITY,knots) 0 != ) == if{ 0 } els{ 1 }
    </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
 
Code:
<PartInfo>
<Name>custom_visibility_beacon_velocity</Name>
<Visibility>
<Parameter>
<Code>
(A:LIGHT BEACON,bool) 
(A:GROUND VELOCITY,knots) 0 != and
if{ 0 } els{ 1 }
</Code>
</Parameter>
</Visibility>
</PartInfo>

Remember: Reverse Polish!
https://en.wikipedia.org/wiki/Reverse_Polish_notation

It should show up in the attachment editor just fine.
 
Thanks for the correction.

It seems like only the light beacon condition is working because this time, the block disappeared, but again, at the end of the pushback. Is like the ground velocity value is ignored. The block remained visible during the pushback and (and the wheels were rotating) so it seems that value is simply ignored.

actually, as I said, I keep light beacon in the other wheel, so in this case both blocks behaved the same. Progress but not where I would like yet

a
 
Bjoern

Some progress here. I think we are getting close but I am stuck. Let me tell you what has happened.

Starting with your last suggestion... all the lights switch on at the very same time that the engines do: after the pushback, so it wouldn't work but I tried (you'll see below).

But I still believe in the combination you suggested of wheel spin and beacon light, makes all sense. So I tried the wheel spin first alone (after quite a bit of trial and error with other options, price to pay for the ones that know nothing about code) and I end up with:

Code:
  <PartInfo>
    <Name>custom_part_vis_blocks</Name>
    <Visibility>
      <Parameter>
        <Code>
      (A:GROUND VELOCITY,knots) 0 != == if{ 1 } els{ 0 }
    </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

That, for the first time, made the block disappear right before the pushback, hooray! (interestingly just about a sec or two before the wheels start to spin ??!!).

However, if the plane has to stop for more than that second or two i.g. waiting for other traffic to cross or land, the blocks come back and will remain until the aircraft moves again (as expected...). So I tried this:

Code:
  <PartInfo>
    <Name>custom_part_vis_blocks</Name>
    <Visibility>
      <Parameter>
        <Code>
      (A:GROUND VELOCITY,knots) 0 != ==
      (A:LIGHT BEACON ON,bool) 0 == ||
      if{ 1 } els{ 0 }
    </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

I tested with both, the "Light beacon" and "light beacon on" (I also tried LIGHT NAV ON instead of beacon). As I result, back to the initial effect. The blocks will only disappear once the pushback has finished. Disappointment.

It seems that lights variables and other variables override the effect of (A:GROUND VELOCITY,knots) 0 != (which so far is the only that really does the trick).

I don't know how to combine (A:GROUND VELOCITY,knots) 0 != with any other variables avoiding that overriding effect produced by variable that show their effect AFTER the pushback, like lights, battery as mentioned.

Cheers
 
Last edited:
First of all, one evaluation condition suffices. Either pick "!=" or "==", not both.

Second, the logic does not seem that sound to me. Let's try it this way...

Code:
<PartInfo>
<Name>custom_part_vis_blocks</Name>
<Visibility>
<Parameter>
<Code>
(A:GROUND VELOCITY,knots) 0 !=
(A:LIGHT BEACON,bool) or
if{ 0 } els{ 1 }
</Code>
</Parameter>
</Visibility>
</PartInfo>

This will evaluate the entire visibility code with a zero ("false") when ground velocity is not zero or the beacon light is on. If none of these conditions are true, i.e. the plane is not moving and the beacon light is off, the visibility will be set to "1" ("true").

If this still won't work, try (A:GENERAL ENG COMBUSTION:1,bool) instead of the beacon light variable. Although I doubt that FSX tracks the engine state of AI aircraft.
 
Well, well , well :)

The code above did the trick. Congratulations Bjoern and thank, you thank you very much, not just for the solution but for the teaching. (I haven't tried the eng combustion yet, too happy to bother today! but I will give it a go for "research")

The logic I was referring to, perhaps no well expressed, was exactly what you've done: use the spinning wheel (ground velocity) to make the block disappear during pushback, and use something else when the plane has to stop between the pushback and take off (at those moments lights have to be already on, so they should work). How to combine them in xml was my challenge, but you did it just beautifully.

To any one reading this, although it's Bjoern's merit, unless he has any inconvenience, feel free to use the code, works like a charm. Remember, it is just a VISIBILITY CONDITION, it is not an animation.

Cheers
 
Sure thing about the code. If it's posted here I basically expect that it gets used. :)

Anyway, I hope that you put the gained knowledge to good use and maybe be able to help others out in the future. And don't forget that every code starts with SimVars and ends with EventIDs. And that it's never too late to learn.
 
I'll do.

The next battle I'm having is with the :var variable. The fact that refers to a gauge value but no way I can understand which gauge is driving me mad.

The y say can have values 1-9 but, what do the mean? specially if I don't even know which gauge is referring to...

Cheers
 
Do you mean G: type variables?

Those are for use within a single gauge and their values do not get shared across gauges. They're great if you need to save on L: vars.
 
Back
Top