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

FS2004 4 position knob for Panel and Cabin lights (SOLVED)

Messages
1,451
Country
mexico
Hello

I have a 3d part knob in the VC which controls the panel and cabin lights. All actions taken by this knob, are meant to be active only if the battery switch is ON and the light master switch is also ON. The solution I came to, provides a fully functional animation for the 4 positions and the code already monitors, controls and activates the Panel Lights as I want to.

Since (A:LIGHT CABIN,bool) has (K:TOGGLE_CABIN_LIGHTS) as the only available K event, I am having trouble to control when the cabin lights are ON or OFF. This issue seems to be trivial; however, I can't find the proper conditions to make this work. The basic idea is described below:

Key 0: Both lights Off
Key 25: Cockpit lights ON
Key 50: Cabin lights ON

Key 75: Both lights ON

A left mouse click or mouse wheel up, controls the knob positions from 0 to 3. The reverse switch action is activated with a right mouse click or using the mouse wheel down (from position 3 to 0).

And this is the code I wrote:
HTML:
      <part>
          <name>MD900_CKP_CAB_lt_knob</name>
              <animation>
                  <parameter>
                      <code>
                          (L:MD_900_CKP_CAB_lights_knob,number) 25 *
                      </code>
                      <lag>300</lag>
                  </parameter>
              </animation>
              <mouserect>
                  <cursor>Hand</cursor>
                  <tooltip_text>Panel/Cabin Lights UP (LMB)/DOWN (RMB)</tooltip_text>
                  <mouse_flags>LeftSingle+RightSingle+WheelUp+WheelDown</mouse_flags>
                  <callback_code>
                        (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or
                            if{
                                (L:MD_900_CKP_CAB_lights_knob,number) ++ 4 min (>L:MD_900_CKP_CAB_lights_knob,number)
                                <!-- Click Sound Effect -->
                                1 (>L:MD_900_Click, number)
                            
                                <!-- Switch position 0, both lights OFF -->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 0 == and
                                    if{
                                        (A:LIGHT PANEL,bool) if { (>K:PANEL_LIGHTS_OFF) }
                                        (A:LIGHT CABIN,bool) if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                                <!-- Switch position 1: Cockpit light ON, Cabin lights OFF -->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 1 == and
                                    if{
                                        (A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_ON) }
                                        (A:LIGHT CABIN,bool) if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                                <!-- Switch position 2: Cockpit light OFF, Cabin lights ON -->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 2 == and
                                    if{
                                        (A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_OFF) }
                                        (A:LIGHT CABIN,bool) ! if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                                <!-- Switch position 3, both lights ON-->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 3 == and
                                    if{
                                        (A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_ON) }
                                        (A:LIGHT CABIN,bool) ! if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                              }
                        (M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == or
                            if{
                                (L:MD_900_CKP_CAB_lights_knob,number) -- 0 max (>L:MD_900_CKP_CAB_lights_knob,number)
                                <!-- Click Sound Effect -->
                                1 (>L:MD_900_Click, number)
                            
                                <!-- Switch position 0, both lights OFF -->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 0 == and
                                    if{
                                        (A:LIGHT PANEL,bool) if { (>K:PANEL_LIGHTS_OFF) }
                                        (A:LIGHT CABIN,bool) if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                                <!-- Switch position 1: Cockpit light ON, Cabin lights OFF -->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 1 == and
                                    if{
                                        (A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_ON) }
                                        (A:LIGHT CABIN,bool) if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                                <!-- Switch position 2: Cockpit light OFF, Cabin lights ON -->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 2 == and
                                    if{
                                        (A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_OFF) }
                                        (A:LIGHT CABIN,bool) ! if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                                <!-- Switch position 3, both lights ON-->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 3 == and
                                    if{
                                        (A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_ON) }
                                        (A:LIGHT CABIN,bool) ! if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                              }
                  </callback_code>
              </mouserect>
      </part>

If I understood well what Tom Gibson once explained in several threads, it is desireable to have the K events in the mouse section because they only be evaluated once if it exist a mouse action. In my book at least, 1 vs 18 evaluations is the way to go. As a side note, this is the only 3d object which includes the logic in the Part code.

Any help, certainly will be very much appreciated.
In advanced, thank you.
Sergio.
 
Last edited:

tgibson

Resource contributor
Messages
11,324
Country
us-california
In switch position 2 you have two ! not symbols; you should only have one. Only switch position 3 should have two not symbols.
 
Messages
1,451
Country
mexico
Hello Tom

So, what I did wrong is that, uhh? For position 2, I need to suppress the "not" symbol from (A:LIGHT CABIN,bool)
I will test this at once!

Thank you my friend, and be well.
Sergio.
;)
 
Messages
1,451
Country
mexico
Didn't work... now the Panel lights are always On. o_O

Edit 1:
The "flip flop" action for the cabin lights doesn't work either. Nevertheless, the panel lights works fine.

Edit 2:
I've implemented a variable to monitor if the cabin lights do something:
HTML:
<!--  Cabin Lights Monitor Variable -->
    <Element>
        <Select>
      <Value>
          (A:LIGHT CABIN,bool)
            if{ 1 (L:MD_900_Cabin_Light_Monitor,bool) }
          (A:LIGHT CABIN,bool) !
            if{ 0 (L:MD_900_Cabin_Light_Monitor,bool) }
      </Value>
        </Select>
    </Element>

This small part of code, is within an invisible gauge which monitors and controls the logic of everything in my model. What I've found, was that (A:LIGHT CABIN,bool) never is ON. :mad:
 
Last edited:
Messages
1,451
Country
mexico
Problem solved!

My main error was to enable conditions for each knob position for both lights at the same time... Now, monitoring and controling each light separately was the key to solve the problem.
Here is my own solution:
HTML:
<!-- Cockpit & Cabin Light Control Knob-->
            <!--  Key   0: Both Lights Off
                    Key 25: Cockpit LT ON
                    Key 50: Cabin ON
                    Key 75: Both Lights ON
                    -->
      <part>
          <name>MD900_CKP_CAB_lt_knob</name>
              <animation>
                  <parameter>
                      <code>
                          (L:MD_900_CKP_CAB_lights_knob,number) 25 *
                      </code>
                      <lag>300</lag>
                  </parameter>
              </animation>
              <mouserect>
                  <cursor>Hand</cursor>
                  <tooltip_text>Panel/Cabin Lights UP (LMB)/DOWN (RMB)</tooltip_text>
                  <mouse_flags>LeftSingle+RightSingle+WheelUp+WheelDown</mouse_flags>
                  <callback_code>
                        (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or
                            if{
                                (L:MD_900_CKP_CAB_lights_knob,number) ++ 4 min (>L:MD_900_CKP_CAB_lights_knob,number)
                                <!-- Click Sound Effect -->
                                1 (>L:MD_900_Click, number)
                                
                                <!-- Switch position 0 or 1: Cabin lights OFF -->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and
                                (L:MD_900_CKP_CAB_lights_knob,number) 0 == (L:MD_900_CKP_CAB_lights_knob,number) 1 == or
                                and
                                    if{ (A:LIGHT CABIN,bool)
                                        if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                                <!-- Switch position 2 or 3: Cabin lights ON -->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and
                                (L:MD_900_CKP_CAB_lights_knob,number) 2 == (L:MD_900_CKP_CAB_lights_knob,number) 3 == or
                                and
                                    if{ (A:LIGHT CABIN,bool) !
                                        if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                                <!-- Switch position 0 or 2: Cockpit light OFF-->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and
                                (L:MD_900_CKP_CAB_lights_knob,number) 0 == (L:MD_900_CKP_CAB_lights_knob,number) 2 == or
                                and
                                    if{
                                        (A:LIGHT PANEL,bool)
                                            if { (>K:PANEL_LIGHTS_OFF) }
                                      }
                                <!-- Switch position 1 or 3: Cockpit light ON-->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and
                                (L:MD_900_CKP_CAB_lights_knob,number) 1 == (L:MD_900_CKP_CAB_lights_knob,number) 3 == or
                                and
                                    if{
                                        (A:LIGHT PANEL,bool) !
                                            if { (>K:PANEL_LIGHTS_ON) }
                                      }
                              }
                        (M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == or
                            if{
                                (L:MD_900_CKP_CAB_lights_knob,number) -- 0 max (>L:MD_900_CKP_CAB_lights_knob,number)
                                <!-- Click Sound Effect -->
                                1 (>L:MD_900_Click, number)
                                
                                <!-- Switch position 0 or 1: Cabin lights OFF -->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and
                                (L:MD_900_CKP_CAB_lights_knob,number) 0 == (L:MD_900_CKP_CAB_lights_knob,number) 1 == or
                                and
                                    if{ (A:LIGHT CABIN,bool)
                                        if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                                <!-- Switch position 2 or 3: Cabin lights ON -->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and
                                (L:MD_900_CKP_CAB_lights_knob,number) 2 == (L:MD_900_CKP_CAB_lights_knob,number) 3 == or
                                and
                                    if{ (A:LIGHT CABIN,bool) !
                                        if{ (>K:TOGGLE_CABIN_LIGHTS) }
                                      }
                                <!-- Switch position 0 or 2: Cockpit light OFF-->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and
                                (L:MD_900_CKP_CAB_lights_knob,number) 0 == (L:MD_900_CKP_CAB_lights_knob,number) 2 == or
                                and
                                    if{
                                        (A:LIGHT PANEL,bool)
                                            if { (>K:PANEL_LIGHTS_OFF) }
                                      }
                                <!-- Switch position 1 or 3: Cockpit light ON-->
                                (L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and
                                (L:MD_900_CKP_CAB_lights_knob,number) 1 == (L:MD_900_CKP_CAB_lights_knob,number) 3 == or
                                and
                                    if{
                                        (A:LIGHT PANEL,bool) !
                                            if { (>K:PANEL_LIGHTS_ON) }
                                      }
                              }
                  </callback_code>
              </mouserect>
      </part>

Hopefully, this will be helpful to someone else.
Thank you and take care.
Sergio.
;)
 
Top