RNP scripts working in version 4.1

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
User avatar
Puukka
Posts: 87
Joined: Sat Oct 02, 2021 1:25 pm
Location: Weißenkirchen in der Wachau

RNP scripts working in version 4.1

#1 Post by Puukka »

Hi all

I´ve just read the irst time, 4.2 comes with a fs2020_rpn(rpn_script) command?
https://siminnovations.com/forums/viewt ... 102#p52102

Hey, why nobody told me here when I asked for help regarding the MD-80? I know, the old MD-80 is not attracting interest :?
https://siminnovations.com/forums/viewtopic.php?t=6807

Anyway, meanwhile I found out by many hours of "try and error" (at least the MD-80 RPNs) implementing them in 4.1 if someone is interested.
Attached a two way and three way switch:

Callbacks by LVARs, the command lines need two commands at once in a specific order. You´ll find out comparing them with the Hubhob published ones, or reading the specific .xml file (MSFS\Community\lsh-maddogx-aircraft\SimObjects\Airplanes\MaddogX\model).
Regards,
Herbert

Two way (also pushbutton commands):
function autot_click(position)
if position == 0 then
switch_set_position(autot_switch, 1)
fs2020_variable_write("L:fgcp_event", "number", 536870931)
fs2020_variable_write("L:fgcp_event", "number", 8211)
elseif position == 1 then
switch_set_position(autot_switch, 0)
fs2020_variable_write("L:fgcp_event", "number", 536870931)
fs2020_variable_write("L:fgcp_event", "number", 8211)
end
end

Three way:
ffunction landing_cb(position, direction)
if direction == -1 then
fs2020_variable_write("L:ext_lights_event", "number", 2147483648)
fs2020_variable_write("L:ext_lights_event", "number", 536870912)
elseif direction == 1 then
fs2020_variable_write("L:ext_lights_event", "number", 536870912)
fs2020_variable_write("L:ext_lights_event", "number", 2147483648)
end
end
Dials working same:
function baro_dial_it(direction)
if direction == 1 then
fs2020_variable_write("L:CM1_efisctrl_event", "number", 8192)
fs2020_variable_write("L:CM1_efisctrl_event", "number", 16384)
elseif direction == -1 then
fs2020_variable_write("L:CM1_efisctrl_event", "number", 16384)
fs2020_variable_write("L:CM1_efisctrl_event", "number", 8192)
end
end
MD-80 - Autopilot Switch.siff
(74.74 KiB) Downloaded 67 times
MD-80 - Landing Lights.siff
(64.35 KiB) Downloaded 67 times
Herbert Puukka

MSFS - CRJ, X-Plane - Citation X, Air Manager, FSHud, Navigraph

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: RNP scripts working in version 4.1

#2 Post by SimPassion »

Hi @Puukka it's you who alert me on the upcoming RPN for MSFS area, I guess I miss the other post reporting this and also not read new addition in the wiki for a while
There's sometime some who are ahead in following changes and you were at least two simmers including you ...
I will have a look into your instruments, the MD8n are just aircrafts I've not already taken time to appropriate the avionics yet, though I really like the cockpit with its specific layout

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: RNP scripts working in version 4.1

#3 Post by SimPassion »

Didn't realize it was of a payware addon, sorry : https://secure.simmarket.com/leonardo-s ... 546).phtml
So I will just try to add the X-Plane compatibility if I'm able

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: RNP scripts working in version 4.1

#4 Post by SimPassion »

Hi Herbert, I've just added x-plane handling in your Autopilot Switch
Feel free to do what you want with this addition

As the FS2020 and X-Plane statements are performing the same action in both ways, then the two function may as well be simplified as below. I've also used SI snippet to get the position reversed ("fif" statement)

Code: Select all

--[[
   MD-80 Autopilot Switch
   Author Herbert Puukka
   
   1.0.1	enjxp_SimPassion	01/27/2023	Add X-Plane handling and shortening in function
   1.0.0	Herbert Puukka		01/27/2023	Initial Release
--]]

img_add_fullscreen("background.png")

function autot_click(position)
	pos = fif(position == 1,0,1)
	switch_set_position(autot_switch, pos)
	fs2020_variable_write("L:fgcp_event", "number", 536870931)
	fs2020_variable_write("L:fgcp_event", "number", 8211)
	xpl_command("laminar/md82cmd/autopilot/autothrottle_switch")
end
autot_switch = switch_add("sw_big_dwn.png", "sw_big_up.png", 18, 47, 45, 115, autot_click)

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

function ss_at(at_on)
	switch_set_position(autot_switch, at_on)
end    
fs2020_variable_subscribe("L:fgcp_autopilot_switch1", "Int", ss_at)
xpl_dataref_subscribe("laminar/md82/autopilot/autothrottle_switch","FLOAT",ss_at)
image.png
 

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: RNP scripts working in version 4.1

#5 Post by SimPassion »

Here's for the landing lights, where I've also added the side handling for X-Plane (Left or Right), let me know which are the values to write in MSFS for Right side and I will add and rework the first function a bit and accordingly, with simplification for the two sims.

Code: Select all

--[[
   MD-80 Landing Switches Left or Right based on user property
   Author Herbert Puukka
   
   1.0.1	enjxp_SimPassion	01/27/2023	Add X-Plane handling and shortening in function
											Add two sides handling for X-Plane
   1.0.0	Herbert Puukka		01/27/2023	Initial Release
--]]

up_side_str	= user_prop_add_enum("LDG LIGHT side","Left,Right","Left", "You can choose one of these choices")
side_str	= user_prop_get(up_side_str)
side_num	= fif(side_str == "Left",2,3)


img_add_fullscreen("background.png")

--landing light
function landing_cb(position, direction)
	if direction == -1 then
		fs2020_variable_write("L:ext_lights_event", "number", 2147483648)
		fs2020_variable_write("L:ext_lights_event", "number", 536870912)
	elseif direction == 1 then
		fs2020_variable_write("L:ext_lights_event", "number", 536870912)
		fs2020_variable_write("L:ext_lights_event", "number", 2147483648)
	end
	if side_num == 2 then
		if direction == -1 then
			xpl_command("laminar/md82cmd/switches/landing_lights_switch_L_dwn")
		elseif direction == 1 then
			xpl_command("laminar/md82cmd/switches/landing_lights_switch_L_up")
		end
	else
		if direction == -1 then
			xpl_command("laminar/md82cmd/switches/landing_lights_switch_R_dwn")
		elseif direction == 1 then
			xpl_command("laminar/md82cmd/switches/landing_lights_switch_R_up")
		end
	end
end
landing_id = switch_add("sw_big_dwn.png", "sw_big_middle.png","sw_big_up.png", 18, 47, 45, 115, landing_cb)

function set_ldg(sw_pos)
    if sw_pos == 2 then 
        sw_pos = 0
    elseif sw_pos == 1 then 
        sw_pos = 1
    elseif sw_pos == 0 then
        sw_pos = 2
    end
    switch_set_position(landing_id, sw_pos)	
end
fs2020_variable_subscribe("L:CM1_winglightl_switch1", "Number", set_ldg)

function xpl_set_ldg(sw_pos)
	pos = sw_pos[side_num] + 1
	set_ldg(pos)
end

xpl_dataref_subscribe("sim/cockpit2/switches/landing_lights_switch","FLOAT[16]",xpl_set_ldg)
 

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: RNP scripts working in version 4.1

#6 Post by SimPassion »

Here's for taxi lights, notice you have to update the values for it to work for MSFS :

Code: Select all

--[[
   MD-80 Taxi Lights
   Author Herbert Puukka
   
   1.0.1	enjxp_SimPassion	01/27/2023	Add X-Plane handling and shortening in function
   1.0.0	Herbert Puukka		01/27/2023	Initial Release
--]]

img_add_fullscreen("background.png")

--landing light
function taxi_cb(position, direction)
	if direction == -1 then
		-- fs2020_variable_write("L:ext_lights_event", "number", 2147483648)
		-- fs2020_variable_write("L:ext_lights_event", "number", 536870912)
		xpl_command("laminar/md82cmd/switches/landing_lights_switch_nose_dwn")
	elseif direction == 1 then
		-- fs2020_variable_write("L:ext_lights_event", "number", 536870912)
		-- fs2020_variable_write("L:ext_lights_event", "number", 2147483648)
		xpl_command("laminar/md82cmd/switches/landing_lights_switch_nose_up")
	end
end
taxi_id = switch_add("sw_big_dwn.png", "sw_big_middle.png","sw_big_up.png", 18, 47, 45, 115, taxi_cb)

function set_taxi(sw_pos)
    if sw_pos == 2 then 
        sw_pos = 0
    elseif sw_pos == 1 then 
        sw_pos = 1
    elseif sw_pos == 0 then
        sw_pos = 2
    end
    switch_set_position(taxi_id, sw_pos)	
end
-- fs2020_variable_subscribe("L:CM1_winglightl_switch1", "Number", set_taxi)

xpl_dataref_subscribe("sim/cockpit2/switches/taxi_light_on","INT",set_taxi)
Here's some inputs on MSFS side :

image.png

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: RNP scripts working in version 4.1

#7 Post by SimPassion »

Just a quick POC on annunciators displays with 14 segment LEDs

image.png
image.png
image.png
 
Last edited by SimPassion on Sat Jan 28, 2023 3:49 am, edited 2 times in total.

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: RNP scripts working in version 4.1

#8 Post by SimPassion »

image.png
image.png
image.png
image.png
image.png
 

User avatar
Puukka
Posts: 87
Joined: Sat Oct 02, 2021 1:25 pm
Location: Weißenkirchen in der Wachau

Re: RNP scripts working in version 4.1

#9 Post by Puukka »

@SimPassion Merci beaucoup Gilles, great, thanks a lot for your help! :)
I will consider the X-Plane 12 default version, or maybe the Rotate version, when it´s been updated for X-Plane 12 too, X-Plane coding is so much easier using the Dataref tool.
Kind regards from Austria,
Herbert
Herbert Puukka

MSFS - CRJ, X-Plane - Citation X, Air Manager, FSHud, Navigraph

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: RNP scripts working in version 4.1

#10 Post by SimPassion »

Puukka wrote: Sat Jan 28, 2023 6:50 am @SimPassion Merci beaucoup Gilles, great, thanks a lot for your help! :)
I will consider the X-Plane 12 default version, or maybe the Rotate version, when it´s been updated for X-Plane 12 too, X-Plane coding is so much easier using the Dataref tool.
Kind regards from Austria,
Herbert
You're welcome Herbert, I've started from your great idea and now discovering the MD-82 in XP12, though far less advanced than the Leonardo, as there's still many not working switches and dials in this default addon. One very good point is the graphics part is very high-level on visual, apart the cabin which is missing additional rework and enhancement. Otherwise cockpit and external PBR are amazing.

Just a few more step forward on my side, I guess I will at least design this one and you will have only to add the MSFS handling on your side.
I've added the A/T, landing and taxi light switch together with the ANNUN TEST LTS switch in the upper left corner.
Just to mention this layout is only a POC and absolutely not the final design to be published.

image.png

With avionics power ON :

image.png
image.png

Viel Spaß beim Fliegen mit dem Madog Herbert @Puukka !!!

image.png
 

Post Reply