Jump to content
The simFlight Network Forums

Aerosoft A320 and FSUIPC - LUA-Code


Recommended Posts

Hello. 

With the help of the Aerosoft A320 LVar list I wrote some LUA-Code to assign Keyboard-Buttons via the FSUIPC "Key Presses" Tab. In additon I found some other code on the internet that I use.
 

For example, turning the flight director on or off does work without any problems. But to toggle the FD does not work at all. It's the case with many more functions, too. Some work and some don't 

 

function Autopilot_FD_on ()
    LVarSet = "L:AB_MPL_FD"
    ipc.writeLvar(LVarSet, 1)
    SmallOverheadPushButtons ()
    DspShow ("FD", "on")
end

function Autopilot_FD_off ()
    LVarSet = "L:AB_MPL_FD"
    ipc.writeLvar(LVarSet, 0)
    SmallOverheadPushButtons ()
    DspShow ("FD", "off")
end

function Autopilot_FD_toggle ()
	if _tl("L:AB_MPL_FD", 0) then
		Autopilot_FD_on ()
	else
		Autopilot_FD_off ()
	end
end

event.flag(0, "Autopilot_FD_off")
event.flag(1, "Autopilot_FD_on")
event.flag(2, "Autopilot_FD_toggle")

Is there an error in this code?

The lua-file is added to the fsuipc.ini file as followed.

[LuaFiles]
1=actions
2=autobreak
3=engine
4=lights
5=spoilers
6=autopilot
7=autopilot_BACK

[Auto]
1=Lua actions
2=Lua autobreak
3=Lua engine
4=Lua lights
5=Lua spoilers
6=Lua autopilot

Are the lua-files added correctly?

I am using the Aerosoft A320 v1.30 and FSUIPC.

Thank you for your help.

Edited by Barlow
Link to comment
Share on other sites

1 hour ago, Barlow said:

Is there an error in this code?

Is it complete there? What is 

_tl("L:AB_MPL_FD", 0)

Did you use the Lua plug-in to Log LVars as they change to see if that FD one did operate with 0 and 1?  What list did you use?

In some aircraft implementations the L:Vars you find are indicators not actuators -- they just indicate the state of the switch to other parts of the cockpit implementation.

Have you considered using Mouse Macros instead?

1 hour ago, Barlow said:

I am using the Aerosoft A320 v1.30 and FSUIPC.

FSUIPC3, FSUIPC4 or FSUIPC5?

1 hour ago, Barlow said:

Are the lua-files added correctly?

Don't edit the [LuaFiles] section. That is generated automatically!

You are loading 6 lua files automatically, no matter what aircraft you load. Is that what you want? And how am I supposed to tell if you are loading the one you are asking questions about? You say some things work. if so, then surely it must be loaded?

Pete

 

 

Link to comment
Share on other sites

36 minutes ago, Pete Dowson said:

Is it complete there?

The code above is the complete code of my autopilot.lua file, which is listed under the [LuaFiles] section - so I guess it's implementet correctly.

 

36 minutes ago, Pete Dowson said:

What is 


_tl("L:AB_MPL_FD", 0)

The IF-clause should check, if the varibale AB_MPL_FD has a value of 0. I took the syntax from a lua-file I found on another topic. I can't really tell you what's the behind that since I am new to LUA (but not new to programming). Is it wrong? What would be the right syntax?

 

 

36 minutes ago, Pete Dowson said:

Did you use the Lua plug-in to Log LVars as they change to see if that FD one did operate with 0 and 1?

I am sorry, I don't understand what you mean by that. :/

 

36 minutes ago, Pete Dowson said:

 What list did you use?

In the documentation directory of my Aerosoft A320 there is a file called "LVArs.cfg". Eventough it is an *.cfg, I assumed that these are all the LVars used for this Airbus. 

This is a snippet of its content. All LVars are listet one underneath the other without any additional informations. 

AB_MCUD2_LD_STS_PAX
AB_MCUD2_LD_STS_CAR
AB_MCUD2_LD_STS_FUEL
AB_MCUD2_LD_TIME
AB_Cabindoor3_target
AB_Cabindoor4_target
SmallOverheadPushButtons;BTN
LightSwitch;BTN
AB_MPL_NDTERR_Bright;DISP

I searched for a few days on the internet but i couldn't find more information the LVars of the Aerosoft Airbus.

 

36 minutes ago, Pete Dowson said:

In some aircraft implementations the L:Vars you find are indicators not actuators -- they just indicate the state of the switch to other parts of the cockpit implementation.

How can I find out, since theres seems to be no real documentation on the LVars of the Aerosoft A320 besides the LVars.cfg. The developers once postet a bigger list for the Airbus Extended, but it is outdated and cannot be opened anymore.
 

36 minutes ago, Pete Dowson said:

FSUIPC3, FSUIPC4 or FSUIPC5?

FSUIPC 4 and FSX.

 

36 minutes ago, Pete Dowson said:

You are loading 6 lua files automatically, no matter what aircraft you load. Is that what you want?

It's not a smart way, but at this point I just didn't pay any attention to profiles, since the AS A320 is the only plane I am using. I just focused on understanding how LUA works and how to use it with FSUIPC and my Airbus.

 

Edited by Barlow
Link to comment
Share on other sites

1 hour ago, Pete Dowson said:

Did you use the Lua plug-in to Log LVars as they change to see if that FD one did operate with 0 and 1? 

In the meantime I checked what you mean by that and used the the "Log LVars" Lua plugin.

It seems, that the FD is affected by two variables.
 

L:AB_MPL_FD = 1.000000

L:AB_MPL_FD = 0.000000

L:set1_AB_MPL_FD = 0.000000


These are the results I found when manually toggeling the FD switch. So it seems, that the FD switch indeed operates with 0 and 1, but I don't know what the purposes of the set1_* LVar is right now.

Link to comment
Share on other sites

57 minutes ago, Barlow said:

The IF-clause should check, if the varibale AB_MPL_FD has a value of 0. I took the syntax from a lua-file I found on another topic. I can't really tell you what's the behind that since I am new to LUA (but not new to programming). Is it wrong? What would be the right syntax?

Well _tl appears here as a function call. I just don't know what that function is.

I would have used the more usual (I think) 

if read.LVar("L:AB_MPL_FD") == 0 then

I don't see how your _tl is reading the LVar to compare with 0. It looks like some function you forgot to include from wherever you got it.

Surely there's a syntax error reported in the FSUIPC4 log. Did you check?

1 hour ago, Barlow said:

In the documentation directory of my Aerosoft A320 there is a file called "LVArs.cfg". Eventough it is an *.cfg, I assumed that these are all the LVars used for this Airbus. 

They might be, but does it tell you how to use them?

1 hour ago, Barlow said:

i couldn't find more information the LVars of the Aerosoft Airbus.

But FSUIPC provides a built-in control to List all current L:Vars and their current values, and there is a live log provided, on screen, by the example Lua plug-in provided to Log them.

1 hour ago, Barlow said:

How can I find out, since theres seems to be no real documentation on the LVars of the Aerosoft A320 besides the LVars.cfg.

I doubt you can unless some other user has experimented and worked it out. I'm surprised they were supplied with the aircraft files -- that is most unusual. The aircraft makers don't provide them for user benefit.

Pete

 

Link to comment
Share on other sites

Hi,

Reading the code provided, I assume Barlow just used code out of LINDA. The used functions like DspShw make me thinking in this direction. Barlow also wrote, that he found some code on the internet.

So the provided code never will run, if he references other functions which are not defined.

Rgds
Reinhard

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.