c172p-team / c172p

A high detailed version of the Cessna 172P aircraft for FlightGear
GNU General Public License v2.0
82 stars 43 forks source link

Ignition switch fails when using the xml animation "Start" #1322

Closed wlbragg closed 4 years ago

wlbragg commented 4 years ago

I'm not sure what changed or why but the issue is if you use the interior view keyed ignition to start the aircraft it fails if you mouse over the "start" hot spot without first clicking on mag 1 and 2 .I don't think this used to be this way and I don't know that we changed any of the code in Models/Interior/Panel/Instruments/magneto-switch/magneto-switch.xml to cause this behavior. Auto start still works and if you first set up the aircraft systems for startup appropriately then the "s" key start still works.

    <!-- Magneto switch -->
    <animation>
        <type>knob</type>
        <object-name>key</object-name>
        <object-name>start</object-name>
        <object-name>magsw</object-name>
        <visible>true</visible>
        <action>
            <binding>
                <command>property-adjust</command>
                <property>/controls/switches/magnetos</property>
                <factor>1</factor>
                <min>0</min>
                <max>3</max>
            </binding>
        </action>
        <increase>
            <binding>
                <command>nasal</command>
                <script>c172p.click("magneto-forward")</script>
            </binding>
        </increase>
        <decrease>
            <binding>
                <command>nasal</command>
                <script>c172p.click("magneto-back")</script>
            </binding>
        </decrease>
        <hovered>
            <binding>
                <command>set-tooltip</command>
                <tooltip-id>magneto-switch</tooltip-id>
                <label>Magnetos: %s</label>
                <property>controls/switches/magnetos</property>
                <mapping>nasal</mapping>
                <script>
                    var m = arg[0];
                    if (m == 1) return 'RIGHT';
                    if (m == 2) return 'LEFT';
                    if (m == 3) return 'BOTH';
                    return 'OFF';
                </script>
            </binding>
        </hovered>
    </animation>

    <!-- Starter -->
    <animation>
        <type>pick</type>
        <object-name>click-S</object-name>
        <visible>false</visible>
        <action>
            <name>starter</name>
            <button>0</button>
            <binding>
                <command>property-assign</command>
                <property>/controls/switches/starter</property>
                <value>1</value>
            </binding>
            <binding>
                <command>nasal</command>
                <script>c172p.click("magneto-forward")</script>
            </binding>
            <mod-up>
                <binding>
                    <command>property-assign</command>
                    <property>/controls/switches/starter</property>
                    <value>0</value>
                </binding>
                <binding>
                    <command>nasal</command>
                    <script>c172p.click("magneto-back")</script>
                </binding>
            </mod-up>
        </action>
        <hovered>
            <binding>
                <command>set-tooltip</command>
                <tooltip-id>starter-switch</tooltip-id>
                <label>Engine Starter</label>
            </binding>
        </hovered>
    </animation>

Or it may be a change in fgdata/Nasal/controls.nas

gilbertohasnofb commented 4 years ago

@wlbragg yes, I can reproduce this. But I suspect this bug has always been present. Neither magneto-switch.xml nor FGDATA's controls.nas have changed in the last 2 years. I think we just did not realise it before, probably because using the s shortcut is so handy, or because by doing the proper pre-flight checks the magnetos would be at BOTH before ignition, or because we would use the mouse wheel to change it to BOTH before starting.

But I agree that this shouldn't happen. Even though the key moves instantaneously from OFF to START, in RL it would need to cross the BOTH position. I suspect this is some issue with the logic in the magneto-switch.xml but I did not spot what is wrong after a quick look. Needs more investigation I guess.

wlbragg commented 4 years ago

@gilbertohasnofb yeah, looking at the start pick code above it's a simple matter of setting mag = 2 when the "start" pick is used. I'll make the change if you want to test an merge to master and I guess pick it to current version and then we can notify Stuart on the list to see if he wants to pick it anywhere.

gilbertohasnofb commented 4 years ago

Yeah sure, open a PR and I will merge it. Do you think this is serious enough to bother Stuart with another cherry-pick? I guess probably yes if users use the mouse to turn the aircraft on.