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

FSX Alternator Toggle

TurboCompound

Resource contributor
Messages
190
I've decided that making an entire panel from scratch would be easier once I have practice "improving" existing panels. I took an aircraft known for its spot-on flight dynamics and excellent sound, but largely uses "dummy" switches instead of actual systems. Right now, I am trying to modify the Generator switches to only turn on if the Generator Master switch is turned on and running. Unfortunately, there are two problems.

1. The switch physically will not flip when the Master is not running, but I would like it to flip, just not do anything while the Master is off. I know why this is, simply because of the Case Value section set that way, but I'm not sure how to write it otherwise.

2. The generators won't actually turn on. I suspect that the "d (>K:TOGGLE_ALTERNATOR1)" is not correct.

Code:
<Gauge Name="Generator1" Version="1.0">
   <Element>
      <Select>
         <Value>(L:DCMasterAvailible,bool) (L:DC_Gen01Switch,Bool) and d (>K:TOGGLE_ALTERNATOR1)</Value>
         <Case Value="0">
            <Image Name="Switch_off2.bmp" ImageSizes="37,74"/>
         </Case>
         <Case Value="1">
            <Image Name="Switch_on2.bmp" ImageSizes="37,74"/>
         </Case>
      </Select>
   </Element>
   <Mouse>
      <Help ID="HELPID_GAUGE_GENERATOR_SWITCH"/>
      <Cursor Type="Hand"/>
      <Click>(L:DC_Gen01Switch,Bool) ! (&gt;L:DC_Gen01Switch,Bool)</Click>
   </Mouse>
</Gauge>

Hopefully you gurus can help me out here.

Thanks
 
Try this instead. Note that you will have to also adjust your (L: DCMasterAvailable,bool) script to turn OFF the alternator(s) if needed separately.
Since this action only takes place during a mouse click, there are two separate "tests" for switch conditions; one for ON and another for OFF:
Code:
<Gauge Name="Generator1" Version="1.0">
  <Element>
    <Select>
      <Value>(L:DC_Gen01Switch,Bool)</Value>
      <Case Value="0">
        <Image Name="Switch_off2.bmp" ImageSizes="37,74"/>
      </Case>
      <Case Value="1">
        <Image Name="Switch_on2.bmp" ImageSizes="37,74"/>
      </Case>
    </Select>
  </Element>
  <Mouse>
    <Help ID="HELPID_GAUGE_GENERATOR_SWITCH"/>
    <Cursor Type="Hand"/>
    <Click>
      (* Set switch position *)
      (L:DC_Gen01Switch,Bool) ! (&gt;L:DC_Gen01Switch,Bool)
 
      (* Turn on Alternator 1 *)
      (L:DCMasterAvailible,bool)
      (L:DC_Gen01Switch,Bool) and
      (A:GENERAL ENG GENERATOR ACTIVE:1,enum) 0 == and
      if{ (>K:TOGGLE_ALTERNATOR1) }
 
      (* Turn off Alternator 1 *)
      (L:DCMasterAvailible,bool) !
      (L:DC_Gen01Switch,Bool) ! or
      (A:GENERAL ENG GENERATOR ACTIVE:1,enum) 1 == or
      if{ (>K:TOGGLE_ALTERNATOR1) }
    </Click>
  </Mouse>
</Gauge>
Alternatively, by placing the "action scripts" in an <Update> section, you can avoid the need to complicate things by adding additional "stuff" to your (L: DCMasterAvailable,bool) script!
Code:
<Gauge Name="Generator1" Version="1.0">
  <Update>
    (* Turn on Alternator 1 *)
    (L:DCMasterAvailible,bool)
    (L:DC_Gen01Switch,Bool) and
    (A:GENERAL ENG GENERATOR ACTIVE:1,enum) 0 == and
    if{ (>K:TOGGLE_ALTERNATOR1) }
 
    (* Turn off Alternator 1 *)
    (L:DCMasterAvailible,bool) !
    (L:DC_Gen01Switch,Bool) ! or
    (A:GENERAL ENG GENERATOR ACTIVE:1,enum) 1 == or
    if{ (>K:TOGGLE_ALTERNATOR1) }
  </Update>
   
  <Element>
    <Select>
      <Value>(L:DC_Gen01Switch,Bool)</Value>
      <Case Value="0">
        <Image Name="Switch_off2.bmp" ImageSizes="37,74"/>
      </Case>
      <Case Value="1">
        <Image Name="Switch_on2.bmp" ImageSizes="37,74"/>
      </Case>
    </Select>
  </Element>
  <Mouse>
    <Help ID="HELPID_GAUGE_GENERATOR_SWITCH"/>
    <Cursor Type="Hand"/>
    <Click>
      (* Set switch position *)
      (L:DC_Gen01Switch,Bool) ! (&gt;L:DC_Gen01Switch,Bool)
    </Click>
  </Mouse>
</Gauge>
 
Interestingly enough, I had come up with more or less the same script while trying to figure it out. Unfortunately, both my script and your script seem to have the same problem. I am unable to turn off the Generator using any of the switches.

This is my script:
Code:
<Gauge Name="Generator1" Version="1.0">
   <Element>
      <Select>
         <Value>(L:DC_Gen01Switch,Bool)</Value>
         <Case Value="0">
            <Image Name="Switch_off2.bmp" ImageSizes="37,74"/>
         </Case>
         <Case Value="1">
            <Image Name="Switch_on2.bmp" ImageSizes="37,74"/>
         </Case>
      </Select>
   </Element>
   <Update>
        (L:DCMasterAvailible,bool) (L:DC_Gen01Switch,Bool) and d (>L:Gen01Engaged,bool)
       
        (L:Gen01Engaged,bool) 1 (A:GENERAL ENG MASTER ALTERNATOR:1,enum) 0 == and
        if{ (>K:TOGGLE_ALTERNATOR1) }
       
        (L:Gen01Engaged,bool) 0 (A:GENERAL ENG MASTER ALTERNATOR:1,enum) 1 == and
        if{ (>K:TOGGLE_ALTERNATOR1) }
    </Update>
   <Mouse>
      <Help ID="HELPID_GAUGE_GENERATOR_SWITCH"/>
      <Cursor Type="Hand"/>
      <Click>(L:DC_Gen01Switch,Bool) ! (&gt;L:DC_Gen01Switch,Bool)</Click>
   </Mouse>
</Gauge>

BB3 shows that both DCMasterAvailible and DC_Gen01Switch work correctly and set Gen01Engaged to 1. In this state, alternator 1 is on. Unfortunately, turning either or both of the two switches (DC Master and DC Gen1) off has no effect, and the alternator remains on, despite all three of the LVars displaying a value of 0.
 
This will work:

Code:
<Update>
    (L:DCMasterAvailible,bool) (L:DC_Gen01Switch,Bool) and  (>L:Gen01Engaged,bool)

    (L:Gen01Engaged,bool)  (A:GENERAL ENG MASTER ALTERNATOR:1,enum) 0 == and
    if{ (>K:TOGGLE_ALTERNATOR1) }

    (L:Gen01Engaged,bool) ! (A:GENERAL ENG MASTER ALTERNATOR:1,enum) 1 == and
    if{ (>K:TOGGLE_ALTERNATOR1) }
</Update>

I removed a d and both 1 and 0 characters; these last ones were the source of your problem.

Tom
 
Back
Top