MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

Go to page 1Go to page 112Go to page 3Go to page 2
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3521
Supporter
Hi Again.
Feel free to do this or not..... I just make recommendations. If you can life with the issue then accept it.

Just about your awnser.
Your right ! This is a INT and a Transform entry can NOT result in something else like a INT .... So no string.

For example this formula will NOT work in "transform" : if($=80808,---,$) or if($=80808,'---',$)
BUT
Mobiflight got for this the COMPARE Tab !
Compare is exactly for this situation and result always in a string instead of a INT.....
There you can do this .... Whatever with a formula or with a direct entry in the THEN and ELSE fields.
If you use a formula get sure the "string part" is written in correct syntax ! In a if(a,b,c) format the String result must be within that symbol >> ' << like 'text'

Have fun !
Good Luck !
2020-06-24 12:20
Avatar
Joe_Snuffy
Posts: 20
Pizman, you are the MAN!!!! :w00t: :w00t: :lol: :thumbup:

Got the dashes"-----" working for VS and got it so it says "Std" on the QNH display when set accordingly. Will work on the HDG and SPD ones later, they will need another Offset to get it working because of the way the push/pull Lvars work. But this is great. Thank you so much, I knew there had to be a way, and when it failed in the Transform area I didn't even try anything in the compare spot.

Have a great day!
2020-06-24 15:07
Avatar
Joe_Snuffy
Posts: 20
https://www.thingiverse.com/thing:4497615

For more added realism, redesigned someone's mod for a military plane to work with the Airbus detent system. This works on the Aerosoft Airbus bundle for FSX for sure, not sure about other sims or planes. It fits into the Hotas X throttle base and replaces the original factory part. The lack of a detent in the right spot has been causing me problems when I come in to land.

I think I'm almost finished with this project, just in time to get back to work on Friday, lol. Have fun all.
2020-06-25 03:02
Avatar
happy1911
Posts: 14
i am so lost i got mobiflight to work with pmdg but trying to figure out how to do lvars for airbus a320. all i am really needing is how to do the led for the autopilot and the 7 segment displays. I tried using the script joe wrote but nothing happened reference below. i tried doing the led for the FD. that is part of the script i used

-- lights up when FD is active
function FD_ind()
FDyn=ipc.readLvar("L:AB_MPL_FD")
ipc.writeUB(0x3341, FDyn)
end
event.Lvar("L:AB_MPL_FD",100,"FD_ind")


And then setting my mobiflight to offset 0x3341 value type INT size 1

in the fsuipc.ini I added the name of the file to the lua file

here is my whole script from joe


--Output device functions here


-- Reads Autopilot Knot setting
function AP_Speed_Setting()
Speed_Set=ipc.readLvar("L:AB_AP_SPEED_Selected")
ipc.writeUD(0x07DC, Speed_Set)
end

--Reads Autopilot Mach Setting
function AP_Mach_Setting()
Mach_Set_raw=ipc.readLvar("L:AB_AP_Mach_Select")
Mach_Set=Mach_Set_raw*100
ipc.writeUD(0x07E4, Mach_Set)
end

-- Reads autopilot heading setting
function AP_HDG_Setting()
Heading_Set=ipc.readLvar("L:AB_AP_HDG_Select")
ipc.writeUW(0x07CC, Heading_Set)
end

--Reads if the Speed/Mach button has been pushed then sets for precondition use
function SPDMACH_Toggle()
SPDMACH_on_off=ipc.readLvar("L:AB_AP_SPDMACH")
ipc.writeUB(0x66D4, SPDMACH_on_off)
end

--Reads if the HDG/TRK button has been pushed then sets for precondition use
function HDGTRK_Toggle()
HDGTRK_on_off=ipc.readLvar("L:AB_AP_HDGTRK")
ipc.writeUB(0x66D6, HDGTRK_on_off)
end

-- Reads autopilot Altitude setting
function AP_Alt_Setting()
Altitude_Set=ipc.readLvar("L:AB_AP_ALT_Select")
ipc.writeUD(0x07D4, Altitude_Set)
end

-- Reads autopilot Vertical Speed setting
function AP_VS_Setting()
VS_Set=ipc.readLvar("L:AB_AP_VS_Select2")
ipc.writeSW(0x07F2, VS_Set)
end

--Reads Autopilot FPA Setting
function AP_FPA_Setting()
FPA_Setter=ipc.readLvar("L:AB_AP_FPA_Select2")
FPA_Set=FPA_Setter*10
ipc.writeSB(0x66D7, FPA_Set)
end



-- check to see if Lvars have changed then call up the proper function

event.Lvar("L:AB_AP_TOC_SPD",100,"AP_Speed_Setting")
event.Lvar("L:AB_AP_HDG_Select",100,"AP_HDG_Setting")
event.Lvar("L:AB_AP_SPDMACH",100,"SPDMACH_Toggle")
event.Lvar("L:AB_AP_ALT_Select",100,"AP_Alt_Setting")
event.Lvar("L:AB_AP_VS_Select2",100,"AP_VS_Setting")
event.Lvar("L:AB_AP_Mach_Select",100,"AP_Mach_Setting")
event.Lvar("L:AB_AP_HDGTRK",100,"HDGTRK_Toggle")
event.Lvar("L:AB_AP_FPA_Select2",100,"AP_FPA_Setting")



--Input device functions here


--Knob setting Hdg
function HDG_SET(offset, value)
ipc.writeLvar("AB_AP_HDG_Select", value)
end

--Knob setting SPD
function SPD_SET(offset, value)
ipc.writeLvar("AB_AP_SPEED_Select", value)
end

--Knob setting MACH
function MACH_SET(offset, valueraw)
value=valueraw/100
ipc.writeLvar("AB_AP_Mach_Select", value)
end

--Toggle SPD/MACH display
function SPDMACH_SET(offset, value)
ipc.writeLvar("AB_AP_SPDMACH", value)
end

--Toggle HDG/TRK display
function HDGTRK_SET(offset, value)
ipc.writeLvar("AB_AP_HDGTRK", value)
end

--Knob setting ALT
function ALT_SET(offset, value)
ipc.writeLvar("AB_AP_ALT_Select", value)
end

--Knob setting VS
function VS_SET(offset, value)
ipc.writeLvar("AB_AP_VS_Select2", value)
end

--Toggle Metric/English display
function Metric_SET(offset, value)
ipc.writeLvar("AB_AP_Metric", value)
end



--input checks for function activation

event.offset("66E0","UD","HDG_SET")
event.offset("07DC","UD","SPD_SET")
event.offset("66D5","UB","SPDMACH_SET")
event.offset("66D6","UB","HDGTRK_SET")
event.offset("07E4","SD","MACH_SET")
event.offset("3349","UD","ALT_SET")
event.offset("334D","SD","VS_SET")
event.offset("66D8","UB","Metric_SET")


--Push/Pull switches functions

--Knob setting Spd
function SPD_pushpull(offset, value)
if (value==2) then
ipc.writeLvar("AB_AP_SPDmode", -1)
else
ipc.writeLvar("AB_AP_SPDmode", value)
end
end

--Knob setting Hdg
function HDG_pushpull(offset, value)
if (value==2) then
ipc.writeLvar("AB_AP_HDGmode", -1)
else
ipc.writeLvar("AB_AP_HDGmode", value)
end
end

--Knob setting Alt
function ALT_pushpull(offset, value)
if (value==2) then
ipc.writeLvar("AB_AP_ALTmode", -1)
ipc.writeLvar("AB_AP_KNOBALT", 0)
else
ipc.writeLvar("AB_AP_ALTmode", value)
end
end

--Knob setting VS
function VS_pushpull(offset, value)
if (value==2) then
ipc.writeLvar("AB_AP_VSAni", -1)
ipc.writeLvar("FMA_Vertmode_act", 4)
else
if (value==1) then
ipc.writeLvar("AB_AP_VSAni", value)
ipc.writeLvar("AB_AP_KNOBALT", 1)
else
ipc.writeLvar("AB_AP_VSAni", value)
end
end
end


--PUSH/PULL switches input

event.offset("66E4","SB","SPD_pushpull")
event.offset("66E5","SB","HDG_pushpull")
event.offset("66E6","SB","ALT_pushpull")
event.offset("66E7","SB","VS_pushpull")




--Button Functions(FD,LS,LOC,AP1,AP2,ATHR,APPR)

--FD status
function FD_on_off(offset, value)
ipc.writeLvar("AB_MPL_FD", value)
end

--LS status
function LS_on_off(offset, value)
ipc.writeLvar("AB_MPL_ILS", value)
end

--LOC status
function LOC_activate(offset, value)
ipc.writeLvar("AB_AP_LOC", value)
if (value==1) then
ipc.writeLvar("AB_AP_LOC2", 0)
else
end
end

--AP1 status
function AP1_toggle(offset, value)
ipc.writeLvar("AB_AP_AP1", value)
end

--ATHR status
function ATHR_on_off(offset, value)
ipc.writeLvar("AB_AP_ATHR", value)
end

--AP2 status
function AP2_toggle(offset, value)
APPR_check=ipc.readLvar("L:AB_AP_LOC2")
if (APPR_check~=1) then
if (value==1) then
ipc.writeLvar("AB_AP_AP2", 1)
ipc.writeLvar("AB_AP_AP1", 0)
else
ipc.writeLvar("AB_AP_AP2", 0)
end
else
ipc.writeLvar("AB_AP_AP2", value)
end
end

--APPR status
function APPR_activate(offset, value)
ipc.writeLvar("AB_AP_LOC2", value)
if (value==1) then
ipc.writeLvar("AB_AP_LOC", 0)
else
end
end

--Baro standard status
function STD_pressure(offset, value)
ipc.writeLvar("AB_MPL_Baro_STD", value)
end


--Buttons with lights

event.offset("3341","UB","FD_on_off")
event.offset("3342","UB","LS_on_off")
event.offset("3343","UB","LOC_activate")
event.offset("3344","UB","AP1_toggle")
event.offset("3345","UB","ATHR_on_off")
event.offset("3346","UB","AP2_toggle")
event.offset("3347","UB","APPR_activate")
event.offset("3348","UB","STD_pressure")



--AP green light indicators for FD,LS,LOC,AP1,ATHR,AP2,APPR


-- lights up when FD is active
function FD_ind()
FDyn=ipc.readLvar("L:AB_MPL_FD")
ipc.writeUB(0x3341, FDyn)
end

-- lights up when LS is active
function LS_ind()
LSyn=ipc.readLvar("L:AB_MPL_ILS")
ipc.writeUB(0x3342, LSyn)
end

-- lights up when LOC is active
function LOC_ind()
LOCyn=ipc.readLvar("L:AB_AP_LOC")
ipc.writeUB(0x3343, LOCyn)
end

-- lights up when AP1 is active
function AP1_ind()
AP1yn=ipc.readLvar("L:AB_AP_AP1")
ipc.writeUB(0x3344, AP1yn)
end

-- lights up when ATHR is active
function ATHR_ind()
ATHRyn=ipc.readLvar("L:AB_AP_ATHR")
ipc.writeUB(0x3345, ATHRyn)
end

-- lights up when AP2 is active
function AP2_ind()
AP2yn=ipc.readLvar("L:AB_AP_AP2")
ipc.writeUB(0x3346, AP2yn)
end

-- lights up when APPR is active
function APPR_ind()
APPRyn=ipc.readLvar("L:AB_AP_LOC2")
ipc.writeUB(0x3347, APPRyn)
end

-- Space holder for preconditon Barometric settings
function inHgorhPa()
HgPa=ipc.readLvar("L:AB_MPL_Baro_Unit")
ipc.writeUB(0x66D9, HgPa)
end


--Indicator light triggers for AP

event.Lvar("L:AB_MPL_FD",100,"FD_ind")
event.Lvar("L:AB_MPL_ILS",100,"LS_ind")
event.Lvar("L:AB_AP_LOC",100,"LOC_ind")
event.Lvar("L:AB_AP_AP1",100,"AP1_ind")
event.Lvar("L:AB_AP_ATHR",100,"ATHR_ind")
event.Lvar("L:AB_AP_AP2",100,"AP2_ind")
event.Lvar("L:AB_AP_LOC2",100,"APPR_ind")
event.Lvar("L:AB_MPL_Baro_Unit",100,"inHgorhPa")
2020-08-07 22:42
Avatar
Joe_Snuffy
Posts: 20
I'm not sure if any of what I posted for people will work with a PMDG plane. This stuff was for the Aerosoft Airbus. So I have no way of telling if those Lvars will work for that plane. I know there are some PMDG guys floating around.

However, if the thing about PMDG is a typo, I noticed that you put the lua file name in the FSUIPC, but did you also start it?

Bellow is the section from my particular FSUIPC, don't copy it exactly, this is for my setup. But you not only have to list the lua files you are using, you also have to start them.

[LuaFiles]
1=APBoard
2=display vals
3=Indicators
4=ipcReady
5=linda
6=log lvars
7=Switches

[Auto]
1=Lua APBoard
2=Lua Indicators
3=Lua Switches

The portion above that says [Auto] is what starts the LUA's, in my case I have three for the panels I have made. This starts the LUA file whne I start FSX, however if I change part of the LUA you have to restart the Flight sim, so it could get frustrating doing it my way, but for me it made the most sense at the time.

One other suggestion, start with just one thing, get it working, then add to it as you build mor confidence that the things are working. All in one go you have no clue what to change first, I had one instance where I accidentally typed a "9" somewhere in the script and until I found that one character, the LUA wouldn't start. I had everything working one second then nothing. Becareful and good luck.
[Last edited by Joe_Snuffy, Yesterday 01:26]
Yesterday 01:15
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 3521
Supporter
Normaly a cockpitbuilder not change something in the LUA script if he finished the Cockpit. So this problem occure only while building and testing phase.

Whatever.... If you read the FSUIPC Manual and some Lua Tutorials you will see...... there are much more ways to Run/Stop Macros or Scripts.

For example instead to the AUTO System ( That start your Mods at beginning with the Sim) you can as i know set them to a specific Aircraft.
Means if the Aircraft e.g. "PMDG B737 NGX Winglets" is loaded then FSUIPC detect this and then run all scripts you define for that. If you end the flight and you load a C172 then the scripts are stoped and e.g. other scripts you locate for the C172 get started.

You also can Start/Stop scripts by a Button or Key command. Like a hidden Switch in cockpit.... First press start the scripts.... Second press stop them or so.
Good Luck !
Yesterday 07:08
Avatar
happy1911
Posts: 14
so i have gotten the buttons and leds to work now trying to figure out how to get my 7 segment display to display the heading and altitude. i have the altitude showing up but it will not update when i change the altitude it stays at 7000


function ALT_SET(offset, value)
ipc.writeLvar("AB_AP_ALT_Select", value)
end


function AP_Alt_Setting()
Altitude_Set=ipc.readLvar("L:AB_AP_ALT_Select")
ipc.writeUD(0x07D4, Altitude_Set)
end
event.Lvar("L:AB_AP_ALT_Select",100,"AP_Alt_Setting")
[Last edited by happy1911, Yesterday 19:18]
Yesterday 17:48
Avatar
Joe_Snuffy
Posts: 20
I don't see an event.offset() line to make the function ALT_SET actually run and change anything.
Today 05:15
Go to page 1Go to page 112Go to page 3Go to page 2