• 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 Switch lit when depressed

euroastar350

Resource contributor
Messages
863
Country
us-delaware
Hi guys,

On my Bell 222. When the switches are in the off position, they don't light up. When depressed, they are lit. Example, the hydraulic switch is in the off position, therefore it is not lit. Now when it is depressed when switching on the hydraulics for flight, it is lit. I have separate textures for the on and off positions. I have them setup on the 2D panels, just to implement them into the virtual cockpit. How would I go about this? Do I need to make 2 copies of that single switch and apply the different textures or just use the single switch? I am at a point where the model is pretty much complete and ready for release, just need to code the final switches to match the 2D panels I have implemented. Any input would be most helpful.
 
Yeah, you'll need two different buttons. One in the "off position and one in the "on" position, with the "off" one being dark and the "on" one being depressed and lit.

Button for the "lit" (=on) position (with the lit up texture):
Code:
<PartInfo>
        <Name>Hyd_Switch_On</Name>
        <AnimLength>100</AnimLength>
        <Visibility>
            <Parameter>
                <Code>
                (L:Hydraulics,bool) 0 !=
                if{ 1 } els{ 0 }
                </Code>
            </Parameter>
        </Visibility>
        <MouseRect> 
        <Cursor>Hand</Cursor> 
        <TooltipText>Switch hydraulics off</TooltipText> 
         <MouseFlags>LeftSingle</MouseFlags> 
          <CallbackCode> 
	(L:Hydraulics,bool) ! (&gt;L:Hydraulics,bool) 		
	   </CallbackCode> 
    </MouseRect> 
</PartInfo>

Button for the "off" position:
Code:
<PartInfo>
        <Name>Hyd_Switch_Off</Name>
        <AnimLength>100</AnimLength>
        <Visibility>
            <Parameter>
                <Code>
                (L:Hydraulics,bool) 1 !=
                if{ 1 } els{ 0 }
                </Code>
            </Parameter>
        </Visibility>
        <MouseRect> 
        <Cursor>Hand</Cursor> 
        <TooltipText>Switch hydraulics on</TooltipText> 
         <MouseFlags>LeftSingle</MouseFlags> 
          <CallbackCode> 
	(L:Hydraulics,bool) ! (&gt;L:Hydraulics,bool) 		
	   </CallbackCode> 
    </MouseRect> 
</PartInfo>

Other than that, if you want a keyframe animated button (depression animation) you'd have to detach the top face of the button, clone it and assign one of the codes above to each clone respectively.

The button's "base" then gets an animation like this:

Code:
<PartInfo>
        <Name>Hyd_Button_Base</Name>
<AnimLength>10</AnimLength>
       <Animation>
      <Parameter>
       <Code>
       (L:Hydraulics,bool) 10 *
       </Code>
      <Lag>100</Lag>
      </Parameter>
     </Animation>

Then just make the button's "base" a parent to the top faces and you should have a moving button.


The L: var is just a placeholder. If you're using the default hydraulics system, use the corresponding A: vars and EventIDs for read out and toggling.
 
Excellent Bjoern, now to code over 20 switches on the helicopter using this method:eek:

I'd first make sure that the method works. ;)


Note:
The "lag" value might have to be changed. I think the algorithm behind the parameter is:
[animation length in seconds] = [number of keyframes]/[lag]
 
Personally, I animate the FRAME for the button, then create two polgons for the FACE of the button, and apply the "mouse action" to both polygons. Both face polygons are Linked to the button FRAME as children.

One polygon is unlighted, the other is the same bitmap but with a lightmap applied. For FSX I simply copy the diffuse texture to the self-illumination slot, then use Additive so it will light up during the daytime as well as at night.

I then use the <Visibility> conditions to swap the polys according to the frame's animation variable.

Even easier is to clone the unlight poly, then slightly 'elevate' the clone just barely in front of the unlighted polygon. This way I don't have to hide it; the lighted one will appear and cover up the unlighted poly!

:cool:
 
Last edited:
Personally, I animate the FRAME for the button, then create two polgons for the FACE of the button, and apply the "mouse action" to both polygons. Both face polygons are Linked to the button FRAME as children.

Well, that's what I was suggesting, too. ;)
 
Why so you were! Imagine that. I misread button's (possessive) for buttons (plural)...

Silly me... :tongue-ti

Well, and it was "base" instead of "frame" in my post. the message was still the same though.

But if euroastar gets two concurrent suggestions, he can't be wrong by following them. :cool: :D
 
Who was it said the America and England are two countries separated by a common language?
Roy
 
Back
Top