MSFS ignition logic - Solution!

Peer support for Air Manager desktop users

Moderators: russ, Ralph

Post Reply
Message
Author
Toddimus
Posts: 33
Joined: Wed Feb 17, 2021 6:01 pm

MSFS ignition logic - Solution!

#1 Post by Toddimus »

Hi folks,

I had been struggling to get my hardware ignition switches to work properly in MSFS. It seemed that the old FSX based events and variables didn't work to accurately have the hardware switch match the sim's switch state.

Well, thanks to the hubhop database, I found a solution that works:

Code: Select all

eng_user_prop = user_prop_add_integer("Engine", 1, 8, 1, "Set the engine number for this magneto switch")

hw_switch_add("Magneto switch", 4, function(position, direction)

    if position == 0 then
--        fs2020_event("MAGNETO".. user_prop_get(eng_user_prop) .. "_OFF")
		fs2020_variable_write("RECIP ENG LEFT MAGNETO:".. user_prop_get(eng_user_prop),"Bool",false)
		fs2020_variable_write("RECIP ENG RIGHT MAGNETO:".. user_prop_get(eng_user_prop),"Bool",false)
    elseif position == 1 then
--        fs2020_event("MAGNETO".. user_prop_get(eng_user_prop) .. "_LEFT")
		fs2020_variable_write("RECIP ENG LEFT MAGNETO:".. user_prop_get(eng_user_prop),"Bool",false)
		fs2020_variable_write("RECIP ENG RIGHT MAGNETO:".. user_prop_get(eng_user_prop),"Bool",true)
    elseif position == 2 then
--        fs2020_event("MAGNETO".. user_prop_get(eng_user_prop) .. "_RIGHT")
		fs2020_variable_write("RECIP ENG LEFT MAGNETO:".. user_prop_get(eng_user_prop),"Bool",true)
		fs2020_variable_write("RECIP ENG RIGHT MAGNETO:".. user_prop_get(eng_user_prop),"Bool",false)
    elseif position == 3 then
--       fs2020_event("MAGNETO".. user_prop_get(eng_user_prop) .. "_BOTH")
		fs2020_variable_write("RECIP ENG LEFT MAGNETO:".. user_prop_get(eng_user_prop),"Bool",true)
		fs2020_variable_write("RECIP ENG RIGHT MAGNETO:".. user_prop_get(eng_user_prop),"Bool",true)
    end

end)
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: MSFS ignition logic - Solution!

#2 Post by Ralph »

There's a (pre-made) hardware function available that does all of this.

Toddimus
Posts: 33
Joined: Wed Feb 17, 2021 6:01 pm

Re: MSFS ignition logic - Solution!

#3 Post by Toddimus »

That's just it. The one available as a pre-made hardware function doesn't work for the left and right magnetos. It only does off and both.

The information dialog box on the pre-made hardware function actually acknowledges that there's an issue with FSX and FS2020 and says "There's nothing we can do about this".
mag_info.png
Well, I found a way to do something about it. :)
There were actually a couple of issues with the pre-made hardware function magneto switch:
1. The FSX (not tested) and the FS2020 left and right magneto events didn't work right because of messed up events in the sim
2.The "user_prop_get" called in the switch position ==1 and ==2 elseif's didn't have anything in parenthesis after the call.
It was this:

Code: Select all

...
    elseif position == 1 then
        if user_prop_get == "LEFT - RIGHT" then
...
when it should have been this:

Code: Select all

...
    elseif position == 1 then
        if user_prop_get(magneto_order) == "LEFT - RIGHT" then
...
Here's a revised .siff file with my fixes implemented.
Generic - Magneto switch - 2020 compatible.siff
(104.5 KiB) Downloaded 120 times
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: MSFS ignition logic - Solution!

#4 Post by Ralph »

I had it working as far as I know. Maybe that comment is old and has to be removed. I'll have a look soon.

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: MSFS ignition logic - Solution!

#5 Post by Ralph »

I'm not sure where you got this from. Is this a hardware function? Mine doesn't have anything in the description, and it works fine.

Toddimus
Posts: 33
Joined: Wed Feb 17, 2021 6:01 pm

Re: MSFS ignition logic - Solution!

#6 Post by Toddimus »

It came from the list of built-in hardware functions. Maybe it's a leftover from the 4.0 beta version? I think I copied the database over from the beta to the production 4.02 folder when I bought the license and moved to the production v4 release.

Is there a way to "clean up" the pre-made instruments and hardware functions in Air Manager? I have a bunch of stuff in there that's probably old and could use updating from the mother ship (i.e. Sim Innovations database).
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: MSFS ignition logic - Solution!

#7 Post by Ralph »

That's probably an old version then. If you remove the magneto hardware functions you have, then download it again, you should get the right one. If you still need it :)

Toddimus
Posts: 33
Joined: Wed Feb 17, 2021 6:01 pm

Re: MSFS ignition logic - Solution!

#8 Post by Toddimus »

Cool. Thanks!
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

Post Reply