Aerosoft official retail partner for Microsoft Flight Simulator !! 
Click here for more information

Jump to content
Graham Young

LVAR's/LUA

Recommended Posts

Hi All,

I have got myself a decent flight control system and am trying to assign some of the functions to the switches and rotaries. I have managed this fine with the PMDG 747 and using offsets and am trying to create a profile for the bus through FSUIPC and have created an lua file to do various functions but am a little confused with some of it. The baro increment and decrement is fine as there is some offsets in the action.lua file I got from the Linda forums over at Avsim but I am struggling to try and get other functions to work.

 

For example trying to map a toggle for the AP1 button and the localiser button, the Localiser button for example:-

 

 

if (ipc.readLvar("L:B_AP_LOC") == 1)then

    ipc.writeLvar("L:B_AP_LOC", 0)

    ipc.writeLvar("L:SmallOverheadPushButtons", 1)
end

 

Have it called APLOCAL_tgl.lua and in the sim can see the option available as an FS Control in FSUIPC, but when I assign it to a button nothing happens, is there a particular parameter I need to set, for it to function (have tried both a 0 and a 1)?

 

Thanks,


Graham

Share this post


Link to post
Share on other sites

Hi,

 

You have a typo in your LVars:

L:AB_AP_LOC would be the correct LVar.

You missed an "A" during copy/paste obviously.

 

Btw.: I also see, that you don't use event-driven code in LUA. You should study the manual for the concept of events. This is much more effective instead of always loading the LUA code each time you press a button.

 

Rgds

Reinhard

 

Share this post


Link to post
Share on other sites

Hi Reinhard,

 

That didn't seem to work either, although I'll have to be honest I am not sure what parameter to set in FSUIPC.

 

Which manual were you referring to for the events? The AS one or FSUIPC?

 

Thanks for the help,


Graham

Share this post


Link to post
Share on other sites

Hi,

 

Check the FSUIPC Lua Library document for the event functionality. In the FSUIPC Lua Plug-Ins zip file you fin a lot of samples, which could help you to develop code.

If you are not firm with programming, you also could search for LINDA, which provides a lot of routines for accessing the A3xx functionality.

 

I include here a reduced sample of a LUA code for my GoFlight hardware, which toggles LOC and APPR. You only have to add this LUA to the [Auto] section of your FSUIPC INI file, so that it is executed at startup. Of course you have to add the correct values for joystick and button number. The event function guarantees, that the routine is waiting for the defined button presses to trigger the referenced function.

 

-- A320_GF_Sample.lua

-- define joystick variables - depends on your system
local GF_Joystick = 157								-- GoFlight joystick number
local GF_JoyButton_VORLOC = 7						-- GoFlight button number VOR/LOC
local GF_JoyButton_APPR = 19						-- GoFlight button number APPR


-- toggle LOC
function LOCToggle (joynum, button, downup)			-- toggle LOC
	ipc.writeLvar("L:AB_AP_LOC", 1 - ipc.readLvar("L:AB_AP_LOC") )
	ipc.writeLvar("L:SmallOverheadPushButtons", 1)
end

-- toggle APPR
function APPRToggle (joynum, button, downup)		-- toggle APPR
	ipc.writeLvar("L:AB_AP_LOC2", 1 - ipc.readLvar("L:AB_AP_LOC2") )
	ipc.writeLvar("L:SmallOverheadPushButtons", 1)
end


-- LOC trigger
event.button(GF_Joystick, GF_JoyButton_VORLOC,   1, "LOCToggle")

-- APPR trigger
event.button(GF_Joystick, GF_JoyButton_APPR,   1, "APPRToggle")

 

Further discussion should be done in the FSUIPC forum, which would be the right place to get additional information.

 

Rgds

Reinhard

 

  • Upvote 1

Share this post


Link to post
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...