I have built a 4 position switch using three photo-switches.
So the switch passes one of three values to my callback function depending on its position (0, 1 or 2). I am having difficulty handling the situation where the variable is not assigned a value. The 'else' part was meant to handle this situation but it is not working.
Here is my code snippet for your comments:-
Code: Select all
function switch_callback (position)
print("The switch got changed to position " .. position)
if (position == 0) then
fsx_variable_write("TRAILING EDGE FLAPS LEFT PERCENT", "Percent", 33)
elseif (position == 1) then
fsx_variable_write("TRAILING EDGE FLAPS LEFT PERCENT", "Percent", 75)
elseif (position == 2) then
fsx_event("FLAPS_DOWN")
else
fsx_event("FLAPS_UP")
end
end
Comments welcome