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

P3D v4 Switch cover animation

In the past, I sometimes copied blank paragraphs into a xml script, making the code unusable!
What i try to say, copy the displayed code lines without empty paragraphs into a new file!
In addition, I would first to try load this code in a simplified or shortened version, maybe as a two way switch or as a light script!
And maybe you should create a new GUID!
 
Where did you get the guid?

If your model is 0 bytes, search the modeldef.xml to make sure it is not a duplicate! I've had that happen more than once myself.
 
What does your xtomdl error log say?

Edit: Error log on my setup says something's wrong in your Mouserect. Is "Release" a valid option?

Edit2: Apparently not. Trying LeftRelease, please wait ...

Edit3: Compile successful using LeftRelease. Testing the mdl, please wait. One thought, shouldn't this patient also have a 'Down_Repeat'?

Edit4: LeftRelease works as intended. Down_Repeat apparently not necessary. Now adding RightRelease ...

Edit5: All correct and present, including the gallons readout. Here is your revised and tested modeldef entry.


Code:
<Animation name="s2t_fuel_test_switch" guid="9d16a6aa-5dac-452c-8408-c57fd504e58a" length="100" type="Sim" typeParam2="s2t_fuel_test_switch" typeParam="AutoPlay" />
<PartInfo>
    <Name>s2t_fuel_test_switch</Name>
    <AnimLength>100</AnimLength>
    <Animation>
        <Parameter>
            <Code>50 (L:s2t_fuel_test_switch, bool) 50 * + </Code>
            <Lag>400</Lag>
        </Parameter>
    </Animation>
    <MouseRect>
        <Cursor>Hand</Cursor>
        <TooltipText>Fuel Gauge Test</TooltipText>
      <MouseFlags>LeftSingle+RightSingle+LeftRelease+RightRelease</MouseFlags>
    <CallbackCode>
      (M:Event) 'LeftSingle' scmp  0 ==
      if{ -1 (>L:s2t_fuel_test_switch, bool) -310 (>L:tank_gauge_test, gallons) }
      (M:Event) 'RightSingle' scmp  0 ==
      if{ 1 (>L:s2t_fuel_test_switch, bool) 310 (>L:tank_gauge_test, gallons) }
      (M:Event) 'LeftRelease' scmp  0 == (M:Event) 'RightRelease' scmp  0 == or
       if{ 0 (>L:s2t_fuel_test_switch, bool) 0 (>L:tank_gauge_test, gallons) }
     </CallbackCode>
    </MouseRect>
</PartInfo>

 
Last edited by a moderator:
Bill the guid was made in the guid generator

Thanks Mjahn that worked perfectly. So release was the issue? I appreciate the help.
 
Yes, no "Release" listed in the SDK, section MouseArea Objects. Always good to have that as a reference. Also make sure you generate an error log for each compile, and there is a switch in FSX.cfg that flags gauge xml errors, too (check or add GaugeDevDebug=1 in section [PANELS]). All of them invaluable for error tracing.
 
Bill the guid was made in the guid generator.
Good! I use an on-line generator and generally have it create 200 GUID numbers at a time. I can then cut/paste them from the bottom as needed.

I also keep some 'template' scripts around to cut down on the typing when creating new modeldef.xml scripts! :cool:
XML:
8bfe3585-cd9a-41a6-8d8e-75fbad6b524a
31cdcc53-b249-41a3-981c-06c9c7ca8ab0
5466cc57-53ab-4e61-b2ac-933e87808381
33405ad6-5096-41f4-a9f8-f056e9fda1a7
8002d18e-406a-4837-b2c5-728f6c27eb54

  <Animation name="" guid="" length="100" type="Sim" typeParam2="" typeParam="AutoPlay" />

  <PartInfo>
    <Name></Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:somevarname,enum)
        </Code>
      </Parameter>
    </Animation>
  </PartInfo>

<Animation name="" guid="" length="" type="Sim" typeParam2="" typeParam="AutoPlay" />

<AnimationRef guid=""/>

  <PartInfo>
    <Name>PartName</Name>
    <AnimLength>5</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:somevarname,bool) 5 *
        </Code>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <CallbackCode>
        (L:somevarname,bool) ! (>L:somevarname,bool)
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
I am in need of some help again. Its just a simple on off switch for rudder boost. Ive played with in and adjusted KF and everything I could think of but the switch just wont move. The tooltip text comes up but no animation/movement.

Code:
  <Animation name="s2t_rudder_assist_switch" guid="bf84caa9-0fdf-4865-819a-00af7204c166" length="5" type="Sim" typeParam2="s2t_rudder_assist_switch" typeParam="AutoPlay" />

  <PartInfo>
    <Name>s2t_rudder_assist_switch</Name>
    <AnimLength>5</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:s2t_rudder_assist_switch,bool) 5 *</Code>
      </Parameter>
    </Animation>
      <MouseRect>
        <Cursor>Hand</Cursor>
        <TooltipText>Rudder Assist</TooltipText>
        <MouseFlags>LeftSingle</MouseFlags>
      </MouseRect>
    </PartInfo>
 
Your Mouserect misses the CallbackCode section and therefore doesn't do anything. Suggest the following (not tested):

Code:
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Rudder Assist</TooltipText>
<CallbackCode>
  (L:s2t_rudder_assist_switch,bool) ! (>L:s2t_rudder_assist_switch,bool)
</CallbackCode>
</MouseRect>
 
Hi I have another question to see if what I am after is possible. I have been creating visibility codes for lights in the cockpit and making quite the headway. I am now working on retardant tank controller and it has a row of lights. I have a "tank power switch" that when flipped powers the controller. When the power switch is flipped all the lights come on for about a second then go off until their respective switch is flipped on the retardant switch panel then they come on solid. I have them coded to come on with their switches I just cant make them do the initial flash. Any help or point in the right direction is much appreciated.
 
I guess my approach to this would be the following manageable pseudocode:

when powerswitch is flipped on set a timecounter to 18 (=one sec duration) and activate a control gauge 'element' that decrements the timecounter until <= 0.

This condition to be added to all lights:

if powerswitch=OFF then all lights OFF
else (powerswitch=ON) if timecounter > 0 show all lights
else (powerswitch ON, timecounter <= 0) if subswitch ON show subswitchlight
 
Last edited by a moderator:
Thanks for the reply mjahn. Im not sure how to implement that into a code. Thats above my pay grade at the moment haha.

I found something similar on here, but not sure I can make it do what Im after

Code:
  <PartInfo>
    <Name>light_tank_Ctrlr_CP_mal</Name>
    <Visibility>
      <Parameter>
        <Code>
          <Visibility>
          <!-- SET THE TIMER 9 SECOND REFERENCE ONLY ONCE IF IN DH RANGE, IF OUT OF RANGE OF DH, RESET TO ZERO -->
          (L:s2t_tank_power_switch,bool) 0 == if{ (P:Absolute time, seconds) 1 + } }
          els{ 0 (>L:s2t_tank_power_switch,bool) }

          <!-- NOW USE THE "APP_DH_TIMER" VAR AS THE ACTUAL TRIGGER FOR THE 2 STATES -->
          (L:s2t_tank_power_switch,bool) 0 != if{

               <!-- THE SOLID STATE AFTER 9 SECONDS -->
           (P:Absolute time, seconds) (L:s2t_tank_power_switch,bool) &gt;  if{ 1 }
           <!-- THE BLINKING STATE BEFORE THE 9 SECOND LIMIT -->
           els{ (P:Absolute time, seconds) 0.5 % 0.25 1 * &gt;  ! }

         <!-- THE VAR IS ZERO -->
          } els{ 0 }
      </Visibility>
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
 
TBH I have no idea what this code is all about. It's documented alright and cleanly written, but it alludes to an APP_DH_TIMER var that isn't referenced anywhere. I generally prefer my own coding to patching somebody else's.

Given my earlier pseudocode and assuming that its logic is correct, the xml version would look about as follows (not tested, of course). I am using the power switch Lvar that you have above, the other Lvars I am inventing ad hoc.

First, once the powerswitch is flipped on, set (L:flashduration, enum) to 18 in its CallbackCode section .

Then the Element to be added to a general Control gauge, if there is one, counting down from 18:

Code:
<Element><Select><Value>
  (L:flashduration, enum) 0 &gt; if{ (L:flashduration, enum) --  (>L:flashduration, enum) }
</Value></Select></Element>

And the vis code to be added to the individual lights tentatively named tanklight_001, tanklight_002 etc as per the pseudocode above:

Code:
<Visibility><Parameter>
<Code>
  (L:s2t_tank_power_switch, bool) ! if{ 0 quit }
  (L:flashduration, enum) 0 &gt; if{ 1 quit }
  (L:tanklight_001, bool) if{ 1 } els{ 0 }
</Code>
</Parameter></Visibility>
 
Last edited by a moderator:
Thanks mjahn Ill try that out.

Could I get someone to look this over and see where my mistake is? My model has landing lights and Pulse lights in the wing. Switch up for landing lights- middle off for both- and switch down for pulse lights.

Code:
  <Animation name="s2t_Switch_LL_PL" guid="6fad9cdc-3578-4204-9aa9-4bc753fd5887" length="50" type="Sim" typeParam2="s2t_Switch_LL_PL" typeParam="AutoPlay" />

  <PartInfo>
    <Name>s2t_Switch_LL_PL</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          25 (L:s2t_Pulse_Landing_switch,bool) 25 * +
        </Code>
      </Parameter>
    </Animation>
    <MouseRect>
         <Cursor>Hand</Cursor>
         <MouseFlags>LeftSingle+RightSingle+Wheel</MouseFlags>
         <CallbackCode>
            (M:Event) 'RightSingle' scmp 0 ==
            (M:Event) 'WheelDown' scmp 0 == or
            if{ (L:s2t_Pulse_Landing_switch,bool) -- -1 max (>L:s2t_Pulse_Landing_switch,bool) }
          
            (M:Event) 'LeftSingle' scmp 0 ==
            (M:Event) 'WheelUp' scmp 0 == or
            if{ (L:s2t_Pulse_Landing_switch,bool) ++ 1 min (>L:s2t_Pulse_Landing_switch,bool) }

            <!-- Switch Down - Pulse Lights ON (Wing Lights...) -->
            (L:s2t_Pulse_Landing_switch,bool) -1 ==
            if
            {
               (L:s2t_Pulse_Landing_switch,bool) -1 == if{ (L:s2t_pulse_light,bool) ! if{ (>L:s2t_pulse_light,bool) } } (L:s2t_Pulse_Landing_switch,bool) 0 == if{ (>K:LANDING_LIGHTS_OFF) }
            }
          
            <!-- Switch Middle - OFF for Landing/Pulse Lights -->
            (L:s2t_Pulse_Landing_switch,bool) 0 ==
            if
            {
               (L:s2t_pulse_light,bool) if{ (&gt;L:s2t_pulse_light,bool) } &amp;&amp;
               (>K:LANDING_LIGHTS_OFF)
            }

            <!-- Switch Up - Landing Light ON (Wing Light...) -->
            (L:s2t_Pulse_Landing_switch,bool) 1 ==
            if
            {
               (L:s2t_Pulse_Landing_switch,bool) 0 == if{ (L:s2t_pulse_light,bool)} } (L:s2t_Pulse_Landing_switch,bool) 1 == if{ (>K:LANDING_LIGHTS_ON) }
            }
         </CallbackCode>
    </MouseRect>
  </PartInfo>
 
First, is 'Wheel' a legit Mouseflag? Have you looked it up in the SDK as advised earlier? Remember, the SDK and the error log are your friends ...

Second, curly brackets need to directly follow any if, and the closing bracket needs a space or para break as in if{ xxx }. Also, opening and closing brackets need to be balanced. Cp. your if{ (L:s2t_pulse_light,bool)} } at the end of your code, which combines the two types of error. Actually, the same double error occurs earlier, too, via a copy-and-paste, evidently.

You really don't need us to find these syntax errors.

Even when all the syntax errors are gone there may of course be errors in logic. For this, and indeed for syntactic well-formedness as well, you better use a programming strategy called stepwise refinement. That is, you start out with the simplest possible structure and verify that it does what you expect it to do. Then, stepwise, you add the refinements, always testing in between. This very gratifyingly ensures that you are on the right track and that the errors are few and easily spotted.

But I applaud your attempts to get the hang of it. And you will if you persist.
 
Last edited by a moderator:
Back
Top