• 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 v2 Alt Alerter

Messages
95
Country
ireland
Hi guys,

Can anybody help me sort out this code for an altitude alerter for my plane ?
When the knob is turned (actually it doesn't actually rotate in the sim) the drums turn extreeemly slowly.. so they need to roll much quicker.
I'm not very well up on xml, just a little tinkering about and see if it works in P3D, so that hasn't worked after much nail biting :confused:
Also, how would I go about creating the alerts... 1000 feet to go to selected alt and 300 feet deviation from same. It's all in made in 3D for P3D :)
Any help appreciated, here's the code I have :

Skip


Code:
<PartInfo>
    <Name>J200_ALTALERTER_knob</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
        (L:Altitude Set, feet) 100 /
        </Code>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Altitude Alert Set Knob</TooltipText>
      <MouseFlags>WheelUp+WheelDown</MouseFlags>
      <CallbackCode>  
        (M:Event) 'WheelUp' scmi 0 ==
        if{ (L:Altitude Set, feet)  ++ 0 max (>L:Altitude Set, feet)  }
    
        (M:Event) 'WheelDown' scmi 0 ==
        if{ (L:Altitude Set, feet)  -- 50000 min (>L:Altitude Set, feet)  }
      </CallbackCode>
    </MouseRect>
  </PartInfo>

<PartInfo>
    <Name>J200_ALTALERTER_drum100</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:Altitude Set, feet) 10/ 10 / 100 % flr</Code>
      </Parameter>
    </Animation>
</PartInfo>

<PartInfo>
    <Name>J200_ALTALERTER_drum1000</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:Altitude Set, feet) 10/ 100 / 100 % flr</Code>
      </Parameter>
    </Animation>
</PartInfo>

<PartInfo>
    <Name>J200_ALTALERTER_drum10000</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:Altitude Set, feet, feet) 10/ 1000 / 100 % flr</Code>
      </Parameter>
    </Animation>
</PartInfo>
 
Could it be the <AnimLength>100</AnimLength> part?

For the alerts you need to assign a variable where you track the alerter's state.
In each state you process conditions that will play sounds, light lamps or switch to another state.

For example:
00. Inactive
Do nothing
10. Armed
If difference < 1000 then play sound once
If difference < 100 then switch to 20
20. Arrived
Play sound once
If difference > 300 then play sound looping
If difference < 300 then stop sound
If difference > 1000 then switch to 30
30. Departed
Do nothing

You can create more states.
For example a state where a sound is to be played once can be divided into two states, one where the sound is started and another where the sound has been played.
 
Instead of incrementing using ++ and --, use 5 + and 5 - instead (to make them turn 5 times faster). Might work. Change the number 5 to make them move slower/faster.
 
Tom,

Thanks for your suggestion.. it worked, but instead of 5 + and 5 -, it took a figure of '100' to get it to roll at a descent rate.

Jeroen,

Thanks also for your suggestion also, your list above reminded me a lot of how BASIC was written many years back... very logical. But alas XML is not so friendly and so, although I understand perfectly your logic I don't have the skill to put it in XML :( . If anybody can offer any code snippets I'd greatly appreciate it.

Skip.
 
A bunch of if statements will do:

XML:
0 (>L:Alt_Alert_State_Found, bool)

(L:Alt_Alert_State, enum) 10 == (L:Alt_Alert_State_Found, bool) ! and if{
  1 (>L:Alt_Alert_State_Found, bool)

  <!-- code for state 10 -->

}

(L:Alt_Alert_State, enum) 20 == (L:Alt_Alert_State_Found, bool) ! and if{
  1 (>L:Alt_Alert_State_Found, bool)

  <!-- code for state 20 -->

}

<!-- and so on -->

<!-- finally -->
(L:Alt_Alert_State_Found, bool) ! if{


  <!-- code if no applicable state -->

}

The Alt_Alert_State_Found variable is used to ensure that only one block will be executed, even if the Alt_Alert_State is changed in a block causing a later block to match.
the last block acts as a default when no other block matched.

You can use this in both the main code loop and the mouse input elements.

It is best to first work out the state-scheme, copy-paste the code structure where needed and then fill it with the rest of the code.
 
Back
Top