Jump to content
Sign in to follow this  
phjvh

Avionics Switch

Recommended Posts

Hi all, I need some help with a Avionics Switch I have made for FS9/FS2004. I have both L/R sides to this gauge; however, I have tied the Avionics Sound with them when they are turned on. I want to have it so that if one side SOUND is turned on already - then when the other side is turned on, it won't make the SOUND and vice-versa.Here is the Code I already have: (there may be a mistake in it ? - but it works so far in turning on/off the avionics switches with the sound)----turn on left avionic------(L:Avionics Snd_L,enum) 1 == if{ 0 (>L:Avionics Snd_L,enum) 1 (>K:TOGGLE_AFTERBURNER1) } els{ (L:Avionics Snd_L,enum) 1 == if{ 0 (>L:Avionics Snd_L,enum) 1 (>K:TOGGLE_AFTERBURNER1) } } 1 (>L:snd_00,enum)----turn off left avionic------(L:Avionics Snd_L,enum) 0 == if{ 1 (>L:Avionics Snd_L,enum) 1 (>K:TOGGLE_AFTERBURNER1) } els{ (L:Avionics Snd_L,enum) 0 == if{ 0 (>L:Avionics Snd_L,enum) 1 (>K:TOGGLE_AFTERBURNER1) } } ----turn on right avionic------(L:Avionics Snd_R,enum) 1 == if{ 0 (>L:Avionics Snd_R,enum) 1 (>K:TOGGLE_AFTERBURNER1) } els{ (L:Avionics Snd_R,enum) 1 == if{ 0 (>L:Avionics Snd_R,enum) 1 (>K:TOGGLE_AFTERBURNER1) } } 1 (>L:snd_00,enum)----turn off right avionic------(L:Avionics Snd_R,enum) 0 == if{ 1 (>L:Avionics Snd_R,enum) 1 (>K:TOGGLE_AFTERBURNER1) } els{ (L:Avionics Snd_R,enum) 0 == if{ 0 (>L:Avionics Snd_R,enum) 1 (>K:TOGGLE_AFTERBURNER1) } }Thanks for any help,Benny

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

So what is it doing now? The first step to finding a bug, is to say, "What is my code doing?" This will often tell you where to llok for your error. The code cannot lie, so whatever it is doing is what it is programed to do.Also, you might basically summarize what algorithm (method) you planned to use to solve the problem. This then lets us in on what you are trying to do, allows us to see if that is where your problem is (rather than code), and also allows us to see where your code does not match your intention.It seems that want to just test if the sound (switch you have chosen) is already "ON", and if so, then not toggle it. Is this your intent?

Share this post


Link to post
Share on other sites

Hi Patrick,What the gauge is now doing:Left avionics switch on - sound comes on.Left avionics switch off - sound does not come on.And, the same for the Right avionics switch.Both sides now have the sound come on when the switches is turned on.This is what I want to happen if the switch is turned on from either the Left or Right side.What I would additionally like to happen:What I want to happen is - If the Left switch is already on for example, then when the right switch is turned on - it will not activate the sound because it has already been activated. Also, the same to happen if it was the Right switch on and then the Left switch would not sound since the gauge sound has already activated.Do I think I have a bug?I don't think I have a bug; I just thought if anybody sees something I could have wrote better, please let me know.

Share this post


Link to post
Share on other sites

Hi,Not tested, but you could try this logic for the switches; only 2 clickspots:Right switch:(L:Right Avionics Switch,enum) 0 == if{ 1 (>L:Right Avionics Switch,enum) (L:Left Avionics Switch,enum) 0 == if{ 1 (>L:Avionics Sound,enum) } } els{ 0 (>L:Right Avionics Switch,enum) (L:Left Avionics Switch,enum) 0 == if{ 0 (>L:Avionics Sound,enum) } } 1 (>L:Click,enum)Left switch:(L:Left Avionics Switch,enum) 0 == if{ 1 (>L:Left Avionics Switch,enum) (L:Right Avionics Switch,enum) 0 == if{ 1 (>L:Avionics Sound,enum) } } els{ 0 (>L:Left Avionics Switch,enum) (L:Right Avionics Switch,enum) 0 == if{ 0 (>L:Avionics Sound,enum) } } 1 (>L:Click,enum)Hope it helps,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...