-------------------------------------------------------
---NAV Lights switch FOR Nord3202 BY RESTAURAVIA---
-------------------------------------------------------

-------------------------DATAREFS---------------------------------------

light_switch = create_dataref("custom/N3202/light_switch","number") --(0=fixed, 1=OFF, 2=blinking)
elec_on = find_dataref("sim/cockpit2/electrical/bus_volts[0]")
nav_lights = find_dataref("sim/cockpit2/switches/navigation_lights_on")
AC_strobe =  find_dataref("sim/cockpit2/switches/strobe_lights_on")
Beacon =  find_dataref("sim/cockpit2/switches/beacon_on")
-------------------------RUNTIME---------------------------------------


function cmd_light_up(phase, duration)
	if phase == 0 then 
    light_switch = light_switch +1
  end
  if light_switch > 2 then 
     light_switch = 2 
  end
end
 
function cmd_light_dn(phase, duration)
	if phase == 0 then 
    light_switch = light_switch -1
  end
  if light_switch < 0 then 
      light_switch = 0
  end 
end

-----------------------RUNTIME------------------
function flight_start()
light_switch = 1
end

function after_physics()
  if elec_on > 15 then
      if light_switch == 2 then
         nav_lights = 1 AC_strobe = 1 Beacon = 1
      elseif light_switch == 0 then
         nav_lights = 1 AC_strobe = 0 Beacon = 0
      else nav_lights = 0 AC_strobe = 0 Beacon = 0
      end
  end
end


--------------COMMANDS-------------------------



---COMMANDE FEUX NAV FIXES-CLIGNOTANTS-------
cmdlightup = create_command("custom/N3202/light_up","",cmd_light_up)
cmdlightdn = create_command("custom/N3202/light_dn","",cmd_light_dn)