function Cowl_Flap(control, Knob_in)
if Knob_Out_Last == nil then Knob_Out_Last = 0 end
Knob_Out = (round((Knob_in + 16383)/328))
if Knob_Out < 0 then Knob_Out = 0 end
ipc.writeLvar("L:Eng1_CowlFlapsLever", Knob_Out)
if Knob_Out > Knob_Out_Last + 0.5 or Knob_Out < Knob_Out_Last - 0.5 then
ipc.display("Cowl Flap = "..Knob_Out, 1) end
Knob_Out_Last = Knob_Out
end
-- rounds the integer
function round(num)
num = tonumber(num)
if num == nil then return 0 end
if num >= 0 then return math.floor(num+.5)
else return math.ceil(num-.5) end
end
-- Assign the Axis to "Offser Word Set" "Offset x66D4"
event.offset(0x66D4,"SW","Cowl_Flap")
function Cowl_Flap(control, Knob_in)
Knob_out
Knob_out_last
round
event.offset(0x66D4,"SW","Cowl_Flap")
ipc.display("Cowl Flap = "..Knob_Out, 1)
fonction-name(offset, value)
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
Retourner vers Tableau de bord
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 16 invités