Jump to content
Sign in to follow this  

New to lua programming - where am I going wrong?

Recommended Posts


After many years of using LINDA in a very basic sense, I've just started seeing if I can use it in a more advanced fashion, and getting involved in the dark arts of lua programming!

I'm starting with the Real Air Spitfire, and have managed to trap the LVar for the air filter lever (Cowl_Air_Lever)...  I've then edited the module using the LINDA editor, which tells me the syntax is OK, and the functions show up and are able to be assigned to joystick buttons.

So far so good....  except it doesn't work....    Here's my initial script

-- ## AirFilter ##

function Carb_Air_Intake_FilterInOperation()

function Carb_Air_Intake_NormalIntake()

(and I've tried it with "Carb_Air_Lever" in quotes and without.

the log shows 

[EVNT] Execute Command = "PR:044F04020:15"
[EVNT] Execute Command = "PR:044F04020:17"

which I think is the joystick ID and button ID, but nothing happens in the cockpit

Any ideas?


Intel i7 7700K @5.1Ghz, 32Gb DDR4, P3D v5.3 / MSFS running on Samsung 970evo plus Nvme SSD, Nvidia RTX2080ti
Samsung 55" curved 4KHDR display, Oculus Rift CV2

Share this post

Link to post
Share on other sites

The functions have the correct syntax. But.

When starting to write any code it is worth studying examples and there are plenty in the LINDA aircraft modules. Here are a couple of recommendations to guide you:

  • Use the Tracer to check that the Lvars work as expected. Sometimes they allow values to read and set, other times you can not set any value and you have to use a different method.
  • The best logic structure is to first test for given value (ie. On) before applying an action (set to Off). For example

function example()

if readLvar(“value”) = 1 then

writeLvar(“value”, 0)



  • When testing a function, you can right click on the function name to run it directly.
  • Turn on Fault Diagnosis Mode (in Maintenance) to provide better debug logging.
  • When a button is pressed, it should be identified in the LINDA Console together with the function called. The [EVNT] statements do not give the full picture.

I hope that helps. Best advice is to study and modify existing code before exploring something completely new.

Edited by ScotFlieger

Andrew Gransden

Scotland, UK

LINDA Support/Developer - VATSIM and BAVirtual - Airbus Flyer

i7 1TB SSD GTX980 - FSX/P3D - Aerosoft Airbus A318/A319/A320/A321 - FS2Crew

Share this post

Link to post
Share on other sites
16 hours ago, CharlieBravoUK said:

I've then edited the module using the LINDA editor,

I could be wrong and, if so, I've no doubts that wiser heads will then correct me. 

Be careful where you edit files. Aircraft have two files: actions.lua and user.lua. It is best to add your changes only to the user.lua file. 

  • 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
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online

  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
  • Create New...