Help needed Lua codes for Leonardo MD-80

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
User avatar
Puukka
Posts: 63
Joined: Sat Oct 02, 2021 1:25 pm

Help needed Lua codes for Leonardo MD-80

#1 Post by Puukka »

I just wonder about the Lua codes.

I see Lvars, as example reading by SPADnext, "L:fgcp_autothrottle_switch1", "Int"
If I use them as example fs2020_variable_write ("L:fgcp_autothrottle_switch1", "Int", 1)
The switch is triggered and flips back at once.

Interestingly in the MaddogX_interior.xml says "bool"

<Name>fgcp_autothrottle_switch1</Name>
<AnimLength>10</AnimLength>
<Animation>
<Parameter>
<Code>10 0 (L:fgcp_autothrottle_switch1, bool) ?</Code>

<MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown</MouseFlags>
<CallbackCode>
(M:Event) 'LeftSingle' scmi 0 == if{ 536870912 7 + (&gt;L:fgcp_event, number) }
(M:Event) 'RightSingle' scmi 0 == if{ 2147483648 7 + (&gt;L:fgcp_event,number) }
(M:Event) 'WheelUp' scmi 0 == if{ 536870912 7 + (&gt;L:fgcp_event, number) }
(M:Event) 'WheelDown' scmi 0 == if{ 2147483648 7 + (&gt;L:fgcp_event,number) }
Hubhob says:

MD_82_FGCP_AP_AUTOTHROTTLE_SWITCH
536870912 7 + (>L:fgcp_event, number)

or as example
MD_82_VC_PARKING_BRAKE_OFF
(L:vc_parking_brake_knob, bool) if{ 536870912 1 + (>L:cockpit_event,number) }

MD_82_VC_PARKING_BRAKE_ON
(L:vc_parking_brake_knob, bool) ! if{ 536870912 1 + (>L:cockpit_event,number) }

If I use these (Mouse events?) as RPN Scrips at Axis und Ohs it works.
How can I use these fo the LUA Code?

Thanks and regards,
Herbert
Herbert Puukka

MSFS - Citation CJ4, X-Plane 12 - Citation X, Air Manager, PF3, Navigraph

User avatar
Puukka
Posts: 63
Joined: Sat Oct 02, 2021 1:25 pm

Re: Help needed Lua codes for Leonardo MD-80

#2 Post by Puukka »

Meanwhile I´ve discovered some coding by try and error, the Autothrottle Switch looks like that.....strange but working including callback
Seems I´ll go on with this project.

function autot_click(position)
if position == 0 then
switch_set_position(autot_switch, 1)
fs2020_variable_write("L:fgcp_event", "number", 536870919)
fs2020_variable_write("L:fgcp_event", "number", 8199)
elseif position == 1 then
switch_set_position(autot_switch, 0)
fs2020_variable_write("L:fgcp_event", "number", 536870919)
fs2020_variable_write("L:fgcp_event", "number", 8199)
end
end
autot_switch = switch_add("sw_big_dwn.png", "sw_big_up.png", 18, 47, 45, 115, autot_click)

--536870912 7 + (>L:fgcp_event, number)
--8192 7 + (>L:fgcp_event, number)

function ss_at(at_on)
if at_on ==1 then
switch_set_position(autot_switch, 1)
elseif at_on ==0 then
switch_set_position(autot_switch, 0)
end
end
fs2020_variable_subscribe("L:fgcp_autothrottle_switch1", "Int", ss_at)

MD-80 - Autothrottle Switch.siff
(74.74 KiB) Downloaded 2 times
Herbert Puukka

MSFS - Citation CJ4, X-Plane 12 - Citation X, Air Manager, PF3, Navigraph

Post Reply