programming lvar on axis

The jack of all trades and the world's most popular high performance GA aircraft
Gypsy Baron
A2A Master Mechanic
Posts: 3396
Joined: 02 Aug 2008, 17:04
Location: San Francisco

Re: programming lvar on axis

Post by Gypsy Baron »

nathanmalo wrote:can you just explain me this part of code:

Code: Select all

function Panel_Light(control, Knob_in)
Function: We declare a new function
Panel_Light : function name

but, (control , Knob_in) , what is this and how to find it (with knob_out_last etc)?
This is the format for calls to the function.

control = what FSX control called the function. Only used if you may have several controls calling the
same function and you need to know which one made the current call. In all my scripts I have only one
'control' calling each script so I ignore this input.

Knob_in = the parameter (data) that is passed to the function by the control that called it. You define the
name so it is rather function specific for easy in understanding what you did 6 months from now :)
It is the data from your potentiometer, +/- 16384, that is passed.

Knob_out_last is just a name for a variable used inside the function so that the current scaled input (Knob_out) data
can be compared with the last scaled Knob_out data and if the 2 are the same, no need to display the change.

This keeps the Lua display from constantly displaying the value of Know_in, the potentiometer data, if
it hasn't changed.

I'm glad you got it working.

Happy Holidays!

Paul

Image

nathanmalo
Airman
Posts: 10
Joined: 22 Dec 2014, 09:34

Re: programming lvar on axis

Post by nathanmalo »

so, if y understand what you say, Knob_in ; Knob_out and knob_out_last are 3 variables.
So i can give an other name without any problem?.

I don't really understand the "control" role...

Gypsy Baron
A2A Master Mechanic
Posts: 3396
Joined: 02 Aug 2008, 17:04
Location: San Francisco

Re: programming lvar on axis

Post by Gypsy Baron »

nathanmalo wrote:so, if y understand what you say, Knob_in ; Knob_out and knob_out_last are 3 variables.
So i can give an other name without any problem?.

I don't really understand the "control" role...
Yes, those are 3 variables. You can re-name them as long as you rename all instances
of each variable.

The 'control' is a pssed parameter that indicates what called (triggered) the function,.

It would be useful if one had a general purpose function that did different things depending
upon which control 'called' the function. "A" calls it and the 'control' is set as "A" so the function
then performs whatever processing is required for "A". Then "C" may call it and the function
then performs the processing needed for "C".


In the case of the script I gave you, it has no purpose other than there MUST be an entry in
the function to receive the passed control. You can not remove it. The format MUST be in the form:

function <function name>(parameter 1, parameter 2) thus we have

function Panel_Light(control, Knob_in) which could also be

function Panel_Light(dummy, data) in which case all instances of "Knob_in" would have
to be renamed "data". 'control' or 'dummy' is just an unused parameter/variable unless the
function processing needs to use it. I never had need to use it but it MUST be there.

Control or dummy or whatever the name is for the n1st parameter is a placeholder to
receive a passed parameter. Just as the 2nd parameter receives the data.

The format is dictated by Lua. This is all in the documentation for Lua scripts I am sure.

Paul

nathanmalo
Airman
Posts: 10
Joined: 22 Dec 2014, 09:34

Re: programming lvar on axis

Post by nathanmalo »

Thanks for your answerd paul!
It's verry instructiv for me.

LUA is very strange when you are a noob ^^


But with people like you, it's more easier!


Best regards.

Nathan

French
Airman Basic
Posts: 5
Joined: 02 Mar 2018, 03:45
Location: NYC

Re: programming lvar on axis

Post by French »

Hello, my name is Sylvain!

That was a great tutorial, I managed to build my first switch panel ( For the Comanche ) and get it running thanks to you guys! I learned a lot, lvar, LUA... very useful.

Just a question thought, since I m all set with my panel light knob, how do I get rid of the LUA display, It keeps popping up everytime I turn the knob. I couldn't figure this out. Any help would be apreciated.

Thank you so much!!

Kindest regards,

Sylvain

alioth
Senior Airman
Posts: 161
Joined: 01 Feb 2017, 17:05

Re: programming lvar on axis

Post by alioth »

If you are using the script several posts above, then you only have to comment or delete the following:
if Knob_Out > Knob_Out_Last + 0.5 or Knob_Out < Knob_Out_Last - 0.5 then
ipc.display("Panel Light = "..Knob_Out, 1) end
Arturo.

French
Airman Basic
Posts: 5
Joined: 02 Mar 2018, 03:45
Location: NYC

Re: programming lvar on axis

Post by French »

Thank you so much Arturo!

Very best!

new reply

Return to “C182 Skylane”

Who is online

Users browsing this forum: No registered users and 7 guests