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

MSFS20 Trouble setting a SimObject value based on two variables

spotlope

FSDevConf team
Messages
346
Country
portugal
Hi guys,

For some reason, I'm stumbling over this code. I've got an air conditioner unit that I'm trying to add to my scenery. The idea is to have the blades spin only when between certain hours (08:00 and 18:00), and only if the ambient temperature is above 20c. So far, I haven't been able to get it to properly evaluation that combination and trigger the animation. I've tried just testing for the time of day, which works fine. I've tried just testing for the temperature, and again that works with no problem. It's the combination of both that's hanging me up, which is why I think the problem is in my evaluation code.

This is what works:

<Value>(E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and if{ 1 } els{ 0 }</Value>

And this works:

<Value>(A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt;= if{ 1 } els{ 0 }</Value>

But this is a no-go:

<Value>(E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and (A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt; and if{ 1 } els{ 0 }</Value>

Can anyone spot the problem?

thanks,
Bill
 
XML:
<Value>((E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and )((A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt;) and if{ 1 } els{ 0 }</Value>

Does this work?
 
XML:
<Value>((E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and )((A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt;) and if{ 1 } els{ 0 }</Value>

Does this work?

Thanks for the input, Dick! Unfortunately, no luck with that syntax either.
 
But this is a no-go:

<Value>(E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and (A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt; and if{ 1 } els{ 0 }</Value>

Can anyone spot the problem?

thanks,
Bill

try adding another and

<Value>(E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and (A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt; and and if{ 1 } els{ 0 }</Value>
 
try adding another and

<Value>(E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and (A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt; and and if{ 1 } els{ 0 }</Value>

Thanks! I gave that a go, but it doesn't work either. I'm starting to wonder if we can even evaluate two variables in a SimObject.
 
I'm starting to wonder if we can even evaluate two variables in a SimObject.
It seems like this is accomplished in joystick animation
Next you'd set up your yokes/sticks to have the following two animations:

  • One horizontal animation that moves the stick left to right, or that rotates the yoke left to right to actuate the ailerons (roll the aircraft).
  • One vertical animation that moves the stick/yoke forward to aft (front to back) and actuates the elevator (pitch).
so I asked ChatGPT4 for opinions and he added a smiley to your code
XML:
<Value>
    ((E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and
    (A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt;=) if{ 1 } els{ 0 }
</Value>
it might be worth a try, he charges me almost fifty cents a day for largely uninspired ideas, but here's one more: you could add louvers that keep the cold drafts out, that way we wouldn't see the spinning blades below 20°.
 
It seems like this is accomplished in joystick animation

so I asked ChatGPT4 for opinions and he added a smiley to your code
XML:
<Value>
    ((E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and
    (A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt;=) if{ 1 } els{ 0 }
</Value>
it might be worth a try, he charges me almost fifty cents a day for largely uninspired ideas, but here's one more: you could add louvers that keep the cold drafts out, that way we wouldn't see the spinning blades below 20°.

Hey thanks, Rick. I think the difference between this scenery simobject and an aircraft is that the roll and pitch animations for a joystick are actually separate anims, requiring a separate single-variable value for each, so not really comparable.

Anyhoo, I tried ChatGPT's version. Same thing. No dice. *sigh*

I'm just going to have the AC cut on when the temp reaches 21c, whether the office is open or not. Hey, I'm not paying the electric bills. ;-)
 
Hi Bill,

<code> not <value> is working for me.
Here is an example with 3 variables:

XML:
 <Component ID="xxx" Node="xxx">
            <Visibility>
                <Parameter>
                  <Code>(E:LOCAL TIME, Seconds) 36000 &gt;= (E:LOCAL TIME, Seconds) 64800 &lt;= and (A:AMBIENT PRECIP STATE, mask) 3.0 &lt; and (E:Time of Day, enum) 2 &lt; and if{ 1 } els{ 0 } </Code>
                </Parameter>
            </Visibility>
        </Component>
 
Theoretically I would expect

Code:
<Value>(E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and (A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt; and if{ 1 } els{ 0 }</Value>

to work.

But I'd write it

Code:
<Value>(E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; (A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt; &amp; &amp; if{ 1 } els{ 0 }</Value>

because I know that is works on aircraft. I always put all the "and" at the back end and stuff can get complicated so I like to format it nicely. For example:

Code:
(A:FUELSYSTEM PUMP ACTIVE:1,bool)
(A:GENERAL ENG STARTER:1,bool) !
(A:FUELSYSTEM VALVE OPEN:1,bool)
(A:FUELSYSTEM TANK LEVEL:1,percent) 0 &gt;
(A:ENG COMBUSTION:1,bool) !
(A:GENERAL ENG THROTTLE LEVER POSITION:1,percent) 10 &gt;
(A:GENERAL ENG THROTTLE LEVER POSITION:1,percent) 30 &lt;
(A:GENERAL ENG MIXTURE LEVER POSITION:1,percent) 50 &gt;
(L:prop_engine_primer) 50 &gt;
(L:prop_engine_primer) 100.1 &lt;
(L:prop_carb_primer,number) 50 &gt;
(L:prop_carb_primer,number) 100.1 &lt;
&amp; &amp; &amp; &amp; &amp; &amp; &amp; &amp; &amp; &amp; &amp;
if{  some code }

If it doesn't work it might indeed be a simobject issue.
 
Theoretically I would expect

Code:
<Value>(E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; and (A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt; and if{ 1 } els{ 0 }</Value>

to work.

But I'd write it

Code:
<Value>(E:LOCAL TIME, Seconds) 28799 &gt; (E:LOCAL TIME, Seconds) 64800 &lt; (A:AMBIENT TEMPERATURE, CELSIUS) 20 &gt; &amp; &amp; if{ 1 } els{ 0 }</Value>

because I know that is works on aircraft. I always put all the "and" at the back end and stuff can get complicated so I like to format it nicely. For example:

Code:
(A:FUELSYSTEM PUMP ACTIVE:1,bool)
(A:GENERAL ENG STARTER:1,bool) !
(A:FUELSYSTEM VALVE OPEN:1,bool)
(A:FUELSYSTEM TANK LEVEL:1,percent) 0 &gt;
(A:ENG COMBUSTION:1,bool) !
(A:GENERAL ENG THROTTLE LEVER POSITION:1,percent) 10 &gt;
(A:GENERAL ENG THROTTLE LEVER POSITION:1,percent) 30 &lt;
(A:GENERAL ENG MIXTURE LEVER POSITION:1,percent) 50 &gt;
(L:prop_engine_primer) 50 &gt;
(L:prop_engine_primer) 100.1 &lt;
(L:prop_carb_primer,number) 50 &gt;
(L:prop_carb_primer,number) 100.1 &lt;
&amp; &amp; &amp; &amp; &amp; &amp; &amp; &amp; &amp; &amp; &amp;
if{  some code }

If it doesn't work it might indeed be a simobject issue.

Ant for the win! Your version worked a treat. Thanks so much! I have learned something new this morning, and I've barely even had my coffee.
 
Back
Top