
defineProperty("en_starter_l", globalPropertyi("sim/custom/xap/en_starter_l"))
defineProperty("en_starter_r", globalPropertyi("sim/custom/xap/en_starter_r"))
defineProperty("ENGN_N1_L", globalPropertyf("sim/flightmodel/engine/ENGN_N1_[0]"))
defineProperty("ENGN_N1_R", globalPropertyf("sim/flightmodel/engine/ENGN_N1_[1]"))
defineProperty("APU_N1_percent", globalPropertyf("sim/cockpit2/electrical/APU_N1_percent"))


defineProperty("sound_mute", globalPropertyi("sim/custom/xap/sound_mute"))
defineProperty("sound_vol", globalPropertyi("sim/custom/xap/sound_vol"))

defineProperty("APU_starter_switch", globalPropertyi("sim/cockpit2/electrical/APU_starter_switch"))

defineProperty("electr_stbi_h", globalPropertyi("sim/custom/xap/electr_stbi_h"))

defineProperty("en_but_run_l", globalPropertyi("sim/custom/xap/en_but_run_l"))
defineProperty("en_but_run_r", globalPropertyi("sim/custom/xap/en_but_run_r"))
defineProperty("electr_extp_h", globalPropertyi("sim/custom/xap/electr_extp_h"))

defineProperty("ground_sp_h", globalPropertyi("sim/custom/xap/ground_sp_h"))

defineProperty("rembf1", globalPropertyi("sim/custom/xap/rembf1"))
defineProperty("rembf2", globalPropertyi("sim/custom/xap/rembf2"))
defineProperty("rembf3", globalPropertyi("sim/custom/xap/rembf3"))
defineProperty("rembf4", globalPropertyi("sim/custom/xap/rembf4"))
defineProperty("rembf5", globalPropertyi("sim/custom/xap/rembf5"))
defineProperty("rembf6", globalPropertyi("sim/custom/xap/rembf6"))
defineProperty("rembf7", globalPropertyi("sim/custom/xap/rembf7"))
defineProperty("rembf8", globalPropertyi("sim/custom/xap/rembf8"))
defineProperty("rembf9", globalPropertyi("sim/custom/xap/rembf9"))
defineProperty("rembf10", globalPropertyi("sim/custom/xap/rembf10"))
defineProperty("rembf11", globalPropertyi("sim/custom/xap/rembf11"))
defineProperty("rembf12", globalPropertyi("sim/custom/xap/rembf12"))
defineProperty("rembf13", globalPropertyi("sim/custom/xap/rembf13"))
defineProperty("rembf14", globalPropertyi("sim/custom/xap/rembf14"))

defineProperty("cockpit_lights", globalPropertyi("sim/cockpit/electrical/cockpit_lights"))
defineProperty("instrument_brightness", globalPropertyi("sim/cockpit/electrical/instrument_brightness"))

defineProperty("right_bat_h", globalPropertyi("sim/custom/xap/right_bat_h"))
defineProperty("left_bat_h", globalPropertyi("sim/custom/xap/left_bat_h"))
defineProperty("bus_tie_h", globalPropertyf("sim/custom/xap/bus_tie_h"))


defineProperty("customslider1", globalPropertyi("sim/custom/xap/customslider1"))
defineProperty("customslider1_r", globalPropertyi("sim/custom/xap/customslider1_r"))
defineProperty("customslider2", globalPropertyi("sim/custom/xap/customslider2"))
defineProperty("customslider2_r", globalPropertyi("sim/custom/xap/customslider2_r"))
defineProperty("customslider3", globalPropertyi("sim/custom/xap/customslider3"))
defineProperty("customslider3_r", globalPropertyi("sim/custom/xap/customslider3_r"))
defineProperty("customslider4", globalPropertyi("sim/custom/xap/customslider4"))
defineProperty("customslider4_r", globalPropertyi("sim/custom/xap/customslider4_r"))

defineProperty("emeright_h", globalPropertyf("sim/custom/xap/emeright_h"))
defineProperty("landlight1h", globalPropertyf("sim/custom/xap/landlight1_h"))
defineProperty("landlight2h", globalPropertyf("sim/custom/xap/landlight2_h"))
defineProperty("taxi_light", globalPropertyf("sim/custom/xap/xap_taxilight_h"))
defineProperty("cablight_h", globalPropertyf("sim/custom/xap/cablight_h"))
defineProperty("entrlight_h", globalPropertyf("sim/custom/xap/entrlight_h"))
defineProperty("crewlit_h", globalPropertyf("sim/custom/xap/crewlit_h"))

defineProperty("wing_insp_h", globalPropertyi("sim/custom/xap/wing_insp_h"))
defineProperty("cmfd_h", globalPropertyf("sim/custom/xap/cmfd_h"))
defineProperty("cpfd_h", globalPropertyf("sim/custom/xap/cpfd_h"))
defineProperty("pmfd_h", globalPropertyf("sim/custom/xap/pmfd_h"))
defineProperty("ppfd_h", globalPropertyf("sim/custom/xap/ppfd_h"))

defineProperty("dome_h", globalPropertyf("sim/custom/xap/dome_h"))
defineProperty("annun_h", globalPropertyf("sim/custom/xap/annun_h"))
defineProperty("cbp_h", globalPropertyf("sim/custom/xap/cbp_h"))
defineProperty("gshldr_h", globalPropertyf("sim/custom/xap/gshldr_h"))
defineProperty("pedestal_h", globalPropertyf("sim/custom/xap/pedestal_h"))
defineProperty("gshldl_h", globalPropertyf("sim/custom/xap/gshldl_h"))


defineProperty("sunscreen20", globalPropertyf("sim/custom/xap/sunscreen20"))
defineProperty("sunscreen10", globalPropertyf("sim/custom/xap/sunscreen10"))
defineProperty("sunscreen21", globalPropertyf("sim/custom/xap/sunscreen21"))
defineProperty("sunscreen11", globalPropertyf("sim/custom/xap/sunscreen11"))

defineProperty("smokebelts_h", globalPropertyi("sim/custom/xap/smokebelts_h"))

defineProperty("mastervol", globalPropertyf("sim/custom/xap/master_vol"))

defineProperty("position_saving", globalPropertyi("sim/custom/xap/position_saving")) -- position saving
defineProperty("livery", globalPropertyi("sim/aircraft/view/acf_livery_index")) -- livery index
defineProperty("flight_time", globalPropertyf("sim/time/total_flight_time_sec"))  -- local time since aircraft was loaded
defineProperty("local_time", globalPropertyf("sim/time/local_time_sec")) -- local time
defineProperty("local_time_sec", globalPropertyf("sim/cockpit2/clock_timer/local_time_seconds")) -- local time sec
defineProperty("ground_speed", globalPropertyf("sim/flightmodel/position/groundspeed")) -- true airspeed
defineProperty("wave_limit_n", globalPropertyi("sim/custom/xap/wave_limit_n")) -- wave limit value

defineProperty("floats", globalPropertyf("sim/cockpit2/controls/speedbrake_ratio")) -- floats position
defineProperty("floats_r", globalPropertyf("sim/flightmodel2/controls/speedbrake_ratio")) -- floats position
defineProperty("floats_rq", globalPropertyf("sim/flightmodel/controls/sbrkrqst")) -- floats position
defineProperty("waterrudder", globalPropertyf("sim/cockpit2/controls/water_rudder_handle_ratio")) -- waterrudder position
defineProperty("tailhook", globalPropertyf("sim/cockpit2/switches/tailhook_deploy")) -- tailhook switch
defineProperty("vinet", globalPropertyi("sim/custom/xap/post_effect"))  -- post effect

defineProperty("switch_1", globalPropertyi("sim/cockpit2/switches/custom_slider_on[0]"))  -- anim_menu
defineProperty("avion_men", globalPropertyi("sim/cockpit2/switches/custom_slider_on[4]"))
defineProperty("switch_6", globalPropertyi("sim/cockpit2/switches/custom_slider_on[5]"))
defineProperty("switch_2", globalPropertyi("sim/cockpit2/switches/custom_slider_on[17]"))  -- left upper door
defineProperty("switch_3", globalPropertyi("sim/cockpit2/switches/custom_slider_on[16]")) -- left down door
defineProperty("switch_4", globalPropertyi("sim/cockpit2/switches/custom_slider_on[15]")) -- right door
defineProperty("switch_5", globalPropertyi("sim/cockpit2/switches/custom_slider_on[18]")) -- front door
defineProperty("switch_7", globalPropertyi("sim/cockpit2/switches/custom_slider_on[14]")) -- eng hood left
defineProperty("switch_8", globalPropertyi("sim/cockpit2/switches/custom_slider_on[13]")) -- eng hood right
defineProperty("switch_14", globalPropertyi("sim/cockpit2/switches/custom_slider_on[08]")) -- cockpit light
defineProperty("switch_15", globalPropertyi("sim/cockpit2/switches/custom_slider_on[07]")) -- salon light
defineProperty("switch_16", globalPropertyi("sim/cockpit2/switches/custom_slider_on[06]")) -- toilet light
defineProperty("switch_20", globalPropertyi("sim/cockpit2/switches/custom_slider_on[1]")) -- switches menu
defineProperty("switch_21", globalPropertyi("sim/cockpit2/switches/custom_slider_on[3]")) -- hide pilot
defineProperty("cop_hide", globalPropertyi("sim/cockpit2/switches/custom_slider_on[2]")) -- hide copilot
defineProperty("switch_22", globalPropertyi("sim/cockpit2/switches/custom_slider_on[9]")) -- touch screen
defineProperty("switch_23", globalPropertyi("sim/cockpit2/switches/custom_slider_on[19]")) -- inside front door
defineProperty("switch_24", globalPropertyi("sim/cockpit2/switches/custom_slider_on[10]")) -- toilet door
defineProperty("switch_25", globalPropertyi("sim/cockpit2/switches/custom_slider_on[11]")) -- right window
defineProperty("switch_26", globalPropertyi("sim/cockpit2/switches/custom_slider_on[12]")) -- left window


defineProperty("paylweight", globalPropertyf("sim/flightmodel/weight/m_fixed")) -- payload weight

defineProperty("gears_status2", globalPropertyi("sim/cockpit2/controls/gear_handle_down"))
defineProperty("gears_status", globalPropertyi("sim/cockpit/switches/gear_handle_status"))
defineProperty("gears_dep_1", globalPropertyi("sim/aircraft/parts/acf_gear_deploy[0]"))
defineProperty("gears_dep_2", globalPropertyi("sim/aircraft/parts/acf_gear_deploy[1]"))
defineProperty("gears_dep_3", globalPropertyi("sim/aircraft/parts/acf_gear_deploy[2]"))


defineProperty("flaprat", globalPropertyf("sim/cockpit2/controls/flap_ratio"))

defineProperty("camera_type", globalPropertyi("sim/graphics/view/view_type"))

defineProperty("quater_1", globalPropertyf("sim/flightmodel/position/q[0]"))
defineProperty("quater_2", globalPropertyf("sim/flightmodel/position/q[1]"))
defineProperty("quater_3", globalPropertyf("sim/flightmodel/position/q[2]"))
defineProperty("quater_4", globalPropertyf("sim/flightmodel/position/q[3]"))

defineProperty("velocity_vx", globalPropertyf("sim/flightmodel/position/local_vx"))
defineProperty("velocity_vy", globalPropertyf("sim/flightmodel/position/local_vy"))
defineProperty("velocity_vz", globalPropertyf("sim/flightmodel/position/local_vz"))

defineProperty("park_brake", globalPropertyf("sim/flightmodel/controls/parkbrake")) -- parking brake
defineProperty("park_brake_handle", globalPropertyf("sim/cockpit2/controls/parking_brake_ratio")) -- parking brake handle


defineProperty("pos_x", globalPropertyf("sim/flightmodel/position/local_x"))
defineProperty("pos_y", globalPropertyf("sim/flightmodel/position/local_y"))
defineProperty("pos_z", globalPropertyf("sim/flightmodel/position/local_z"))

defineProperty("latitude", globalPropertyf("sim/flightmodel/position/latitude"))
defineProperty("longitude", globalPropertyf("sim/flightmodel/position/longitude"))
defineProperty("elevation", globalPropertyf("sim/flightmodel/position/elevation"))


defineProperty("engn_prop1", globalPropertyf("sim/flightmodel/engine/ENGN_prop[0]"))
defineProperty("engn_prop2", globalPropertyf("sim/flightmodel/engine/ENGN_prop[1]"))
defineProperty("engn_throt1", globalPropertyf("sim/cockpit2/engine/actuators/throttle_ratio[0]"))
defineProperty("engn_throt2", globalPropertyf("sim/cockpit2/engine/actuators/throttle_ratio[1]"))
defineProperty("proprot1", globalPropertyf("sim/flightmodel/engine/ENGN_N1_[0]"))
defineProperty("proprot2", globalPropertyf("sim/flightmodel/engine/ENGN_N1_[1]"))
defineProperty("startup_running", globalPropertyi("sim/operation/prefs/startup_running"))

defineProperty("ignition1", globalPropertyi("sim/cockpit/engine/ignition_on[0]")) -- ignition 1 selector
defineProperty("ignition2", globalPropertyi("sim/cockpit/engine/ignition_on[1]")) -- ignition 2 selector

defineProperty("fuelselector", globalPropertyi("sim/cockpit/engine/fuel_tank_selector")) -- fuel_selector

defineProperty("eng1mixt", globalPropertyf("sim/cockpit2/engine/actuators/mixture_ratio[0]")) -- engine 1 mixture for cut-off
defineProperty("eng2mixt", globalPropertyf("sim/cockpit2/engine/actuators/mixture_ratio[1]")) -- engine 2 mixture for cut-off


defineProperty("bat1", globalPropertyi("sim/custom/xap/left_bat_h")) -- battery 1 on/off
defineProperty("generator", globalPropertyi("sim/cockpit2/electrical/generator_on[0]")) -- generator on/off
defineProperty("bat2", globalPropertyi("sim/custom/xap/right_bat_h")) -- battery 2 on/off

defineProperty("avionics_power", globalPropertyf("sim/cockpit2/switches/avionics_power_on")) -- avionics power switch
defineProperty("autopilot", globalPropertyf("sim/cockpit/autopilot/autopilot_mode")) -- autopilot mode

defineProperty("aud_panel_pw", globalPropertyi("sim/custom/xap/aud_panel_pw"))
defineProperty("comnav1_pw", globalPropertyf("sim/cockpit2/radios/actuators/com1_power"))
defineProperty("comnav2_pw", globalPropertyf("sim/cockpit2/radios/actuators/com2_power"))
defineProperty("gps_pw", globalPropertyf("sim/custom/xap/gps_pw"))
defineProperty("dme_power", globalPropertyf("sim/cockpit2/radios/actuators/dme_power"))
defineProperty("adf_power", globalPropertyf("sim/cockpit2/radios/actuators/adf1_power"))
defineProperty("trans_mode", globalPropertyf("sim/cockpit/radios/transponder_mode"))


defineProperty("nav_lights", globalPropertyi("sim/custom/xap/nav_h")) -- nav/logo lights on/off
defineProperty("strobe", globalPropertyi("sim/custom/xap/strobe_h")) -- beacon/strobe light on/off

defineProperty("fueltank1", globalPropertyf("sim/flightmodel/weight/m_fuel[0]"))
defineProperty("fueltank2", globalPropertyf("sim/flightmodel/weight/m_fuel[1]"))
defineProperty("fueltank3", globalPropertyf("sim/flightmodel/weight/m_fuel[2]"))
defineProperty("fueltank4", globalPropertyf("sim/flightmodel/weight/m_fuel[3]"))
defineProperty("fueltank5", globalPropertyf("sim/flightmodel/weight/m_fuel[4]"))
defineProperty("fueltank6", globalPropertyf("sim/flightmodel/weight/m_fuel[5]"))

defineProperty("elevtrim", globalPropertyf("sim/cockpit2/controls/elevator_trim"))
defineProperty("ailtrim", globalPropertyf("sim/cockpit2/controls/aileron_trim"))
defineProperty("rudtrim", globalPropertyf("sim/cockpit2/controls/rudder_trim"))

defineProperty("n1perc1", globalPropertyf("sim/cockpit2/engine/indicators/N1_percent[0]"))
defineProperty("n2perc1", globalPropertyf("sim/cockpit2/engine/indicators/N2_percent[0]"))
defineProperty("n1perc2", globalPropertyf("sim/cockpit2/engine/indicators/N1_percent[1]"))
defineProperty("n2perc2", globalPropertyf("sim/cockpit2/engine/indicators/N2_percent[1]"))

defineProperty("propmode1", globalPropertyi("sim/flightmodel/engine/ENGN_propmode[0]"))
defineProperty("propmode2", globalPropertyi("sim/flightmodel/engine/ENGN_propmode[1]"))
defineProperty("propmode3", globalPropertyi("sim/flightmodel/engine/ENGN_propmode[2]"))
defineProperty("propmode4", globalPropertyi("sim/flightmodel/engine/ENGN_propmode[3]"))
defineProperty("propmode5", globalPropertyi("sim/flightmodel/engine/ENGN_propmode[4]"))
defineProperty("propmode6", globalPropertyi("sim/flightmodel/engine/ENGN_propmode[5]"))
defineProperty("propmode7", globalPropertyi("sim/flightmodel/engine/ENGN_propmode[6]"))
defineProperty("propmode8", globalPropertyi("sim/flightmodel/engine/ENGN_propmode[7]"))



defineProperty("jalousie1", globalPropertyf("sim/custom/xap/jalousie1"))
defineProperty("jalousie2", globalPropertyf("sim/custom/xap/jalousie2"))
defineProperty("jalousie3", globalPropertyf("sim/custom/xap/jalousie3"))
defineProperty("jalousie4", globalPropertyf("sim/custom/xap/jalousie4"))
defineProperty("jalousie5", globalPropertyf("sim/custom/xap/jalousie5"))
defineProperty("jalousie6", globalPropertyf("sim/custom/xap/jalousie6"))

defineProperty("jalousie7", globalPropertyf("sim/custom/xap/jalousie7"))
defineProperty("jalousie8", globalPropertyf("sim/custom/xap/jalousie8"))
defineProperty("jalousie9", globalPropertyf("sim/custom/xap/jalousie9"))
defineProperty("jalousie10", globalPropertyf("sim/custom/xap/jalousie10"))
defineProperty("jalousie11", globalPropertyf("sim/custom/xap/jalousie11"))
defineProperty("jalousie12", globalPropertyf("sim/custom/xap/jalousie12"))

defineProperty("table1", globalPropertyf("sim/custom/xap/table1"))
defineProperty("table2", globalPropertyf("sim/custom/xap/table2"))
defineProperty("table3", globalPropertyf("sim/custom/xap/table3"))
defineProperty("table4", globalPropertyf("sim/custom/xap/table4"))

defineProperty("pcush", globalPropertyf("sim/custom/xap/p_cush"))
















starter_1 = findCommand("sim/starters/engage_starter_1")  -- simulator command for starter 1
starter_2 = findCommand("sim/starters/engage_starter_2")  -- simulator command for starter 2


defineProperty("ralt_height", globalPropertyf("sim/cockpit2/gauges/indicators/radio_altimeter_height_ft_pilot"))
defineProperty("hd_position", globalPropertyf("sim/flightmodel/position/R")) -- heading

defineProperty("headposx", globalPropertyf("sim/graphics/view/pilots_head_x"))
defineProperty("headposy", globalPropertyf("sim/graphics/view/pilots_head_y"))
defineProperty("headposz", globalPropertyf("sim/graphics/view/pilots_head_z"))
defineProperty("headpsi", globalPropertyf("sim/graphics/view/pilots_head_psi"))
defineProperty("headthe", globalPropertyf("sim/graphics/view/pilots_head_the"))





defineProperty("aircond_airsource", globalPropertyi("sim/custom/xap/aircond_airsource"))
defineProperty("antice_wshld_l_h", globalPropertyi("sim/custom/xap/antice_wshld_l_h"))
defineProperty("antice_probe_l_h", globalPropertyi("sim/custom/xap/antice_probe_l_h"))
defineProperty("antice_probe_r_h", globalPropertyi("sim/custom/xap/antice_probe_r_h"))
defineProperty("antice_wngsource_r", globalPropertyi("sim/custom/xap/antice_wngsource_r"))
defineProperty("antice_wshld_r_h", globalPropertyi("sim/custom/xap/antice_wshld_r_h"))
defineProperty("oxigen_ox", globalPropertyi("sim/custom/xap/oxigen_ox"))
defineProperty("electr_apugen_h", globalPropertyi("sim/custom/xap/electr_apugen_h"))
defineProperty("electr_gen_r_h", globalPropertyi("sim/custom/xap/electr_gen_r_h"))
defineProperty("electr_gen_l_h", globalPropertyi("sim/custom/xap/electr_gen_l_h"))
defineProperty("electr_stbi_h", globalPropertyi("sim/custom/xap/electr_stbi_h"))
defineProperty("left_bat_h", globalPropertyi("sim/custom/xap/left_bat_h"))
defineProperty("right_bat_h", globalPropertyi("sim/custom/xap/right_bat_h"))
defineProperty("nws_h", globalPropertyi("sim/custom/xap/nws_h"))
defineProperty("fuel_xpump_r", globalPropertyi("sim/custom/xap/fuel_xpump_r"))
defineProperty("fuel_xpump_l", globalPropertyi("sim/custom/xap/fuel_xpump_l"))
defineProperty("bleed_air_mode", globalPropertyi("sim/cockpit2/pressurization/actuators/bleed_air_mode"))
defineProperty("bleed_xbleed_h", globalPropertyi("sim/custom/xap/bleed_xbleed_h"))
defineProperty("bleed_apu_h", globalPropertyi("sim/custom/xap/bleed_apu_h"))
defineProperty("en_but_run_l", globalPropertyi("sim/custom/xap/en_but_run_l"))
defineProperty("en_but_run_r", globalPropertyi("sim/custom/xap/en_but_run_r"))
defineProperty("pedestal_h", globalPropertyf("sim/custom/xap/pedestal_h"))
defineProperty("gshldl_h", globalPropertyf("sim/custom/xap/gshldl_h"))
defineProperty("gshldr_h", globalPropertyf("sim/custom/xap/gshldr_h"))
defineProperty("cbp_h", globalPropertyf("sim/custom/xap/cbp_h"))
defineProperty("aux_hpump_h", globalPropertyi("sim/custom/xap/aux_hpump_h"))
defineProperty("l_hpump_h", globalPropertyi("sim/custom/xap/l_hpump_h"))
defineProperty("r_hpump_h", globalPropertyi("sim/custom/xap/r_hpump_h"))
defineProperty("ptu_h", globalPropertyi("sim/custom/xap/ptu_h"))
defineProperty("cablight_h", globalPropertyf("sim/custom/xap/cablight_h"))
defineProperty("strobe_h", globalPropertyf("sim/custom/xap/strobe_h"))
defineProperty("nav_h", globalPropertyf("sim/custom/xap/nav_h"))
defineProperty("emeright_h", globalPropertyf("sim/custom/xap/emeright_h"))
defineProperty("smokebelts_h", globalPropertyi("sim/custom/xap/smokebelts_h"))
defineProperty("landlight1_h", globalPropertyf("sim/custom/xap/landlight1_h"))
defineProperty("landlight2_h", globalPropertyf("sim/custom/xap/landlight2_h"))
defineProperty("xap_taxilight_h", globalPropertyf("sim/custom/xap/xap_taxilight_h"))
defineProperty("gust_lock", globalPropertyf("sim/custom/xap/gust_lock"))
defineProperty("gust_lock_anm", globalPropertyf("sim/custom/xap/gust_lock_anm"))


local quater_1_last = get(quater_1)
local quater_2_last = get(quater_2)
local quater_3_last = get(quater_3)
local quater_4_last = get(quater_4)
local park_brake_last = get(park_brake)
local position_saving_last = get(position_saving)
local livery_last = get(livery)
local toil_door = get(switch_24)
local in_fr_door = get(switch_23)
local r_window = get(switch_25)
local l_window = get(switch_26)
local r_engn_hood = get(switch_8)
local l_engn_hood = get(switch_7)
local water_rud = get(tailhook)
local fr_door = get(switch_5)
local r_door = get(switch_4)
local l_up_door = get(switch_2)
local l_dn_door =  get(switch_3)
local camera_last = get(camera_type)
local elevation_last = get(elevation)
local longitude_last = get(longitude)
local latitude_last = get(latitude)
local gears_dep_1_last = get(gears_dep_1)
local gears_dep_2_last = get(gears_dep_2)
local gears_dep_3_last = get(gears_dep_3)
local vinet_last = get(vinet)

local anim_menu = get(switch_1)
local switch_menu = get(switch_20)
local hide_pilot = get(switch_21)
local hide_touch = get(switch_22)
local toil_light =  get(switch_16)
local salon_light =  get(switch_15)
local cock_light = get(switch_14)
local floats_dep_last = get(floats_r)

local start_seq = 0




last_states = {start_seq}
set(instrument_brightness, 1)
set(cockpit_lights, 1)


tab = {}
-- read file
local filename = panelDir .. "/settings.ini"
local file = io.open(filename, "r")
--print(file)
if file then
 local lines = file:read("*a")
 for k, v in string.gmatch(lines, "(%w+) = (%C+)") do
  tab[k] = v
 end
 file:close()

end

set(vinet, tab["vinet"])
set(position_saving, tab["positionsaving"])
set(wave_limit_n, tab["wavelimit"])



local rpm1 = tonumber(tab["proprot1"])
local rpm2 = tonumber(tab["proprot2"])
local autopaltmode = tonumber(tab["autopmode"])





if get(startup_running) == 1 and get(position_saving) < 0.5 then

set(antice_wngsource_r, 1)
set(antice_wshld_l_h,1)
set(antice_wshld_r_h, 1)
set(antice_probe_l_h,1)
set(antice_probe_r_h,1)
set(oxigen_ox, 1)
set(electr_apugen_h, 1)
set(aircond_airsource, 1)
set(nws_h, 1)
set(electr_apugen_h , 1)
set(electr_gen_r_h , 1)
set(electr_gen_l_h , 1)
set(electr_stbi_h , 1)
set(left_bat_h , 1)
set(right_bat_h , 1)
set(fuel_xpump_r, 1)
set(fuel_xpump_l, 1)
set(bleed_air_mode, 1)
set(bleed_xbleed_h, 1)
set(bleed_apu_h, 1)
set(en_but_run_l, 1)
set(en_but_run_r, 1)
set(pedestal_h, 1)
set(gshldl_h, 1)
set(gshldr_h, 1)
set(cbp_h, 1)
set(rembf1,1)
set(rembf2,1)
set(rembf3,1)
set(rembf4,1)
set(rembf5,1)
set(rembf6,1)
set(rembf7,1)
set(rembf8,1)
set(rembf9,1)
set(rembf10,1)
set(rembf11,1)
set(rembf12,1)
set(rembf13,1)
set(rembf14,1)
set(jalousie1, 1)
set(jalousie2, 1)
set(jalousie3, 1)
set(jalousie4, 1)
set(jalousie5, 1)
set(jalousie6, 1)
set(jalousie7, 1)
set(jalousie8, 1)
set(jalousie9, 1)
set(jalousie10, 1)
set(jalousie11, 1)
set(jalousie12, 1)
set(ground_sp_h, 1)
set(aux_hpump_h,1)
set(l_hpump_h,1)
set(r_hpump_h,1)
set(ptu_h,1)
set(cablight_h, 1)
set(strobe_h, 2)
set(nav_h, 1)
set(emeright_h, 1)
set(smokebelts_h, 2)
set(landlight1_h, 1)
set(landlight2_h, 1)
set(xap_taxilight_h, 2)
set(gust_lock, 0)
set(gust_lock_anm, 0)
end



apu_b_start = findCommand("sim/electrical/APU_start")
fast_start = findCommand("sim/custom/xap/fast_start")
 function faststartHandler(phase)
     if 0 == phase then
		set(left_bat_h , 1)
		set(right_bat_h , 1)
		set(rembf1,1)
		set(rembf2,1)
		set(rembf3,1)
		set(rembf4,1)
		set(rembf5,1)
		set(rembf6,1)
		set(rembf7,1)
		set(rembf8,1)
		set(rembf9,1)
		set(rembf10,1)
		set(rembf11,1)
		set(rembf12,1)
		set(rembf13,1)
		set(rembf14,1)
		set(antice_wngsource_r, 1)
		set(antice_wshld_l_h,1)
		set(antice_wshld_r_h, 1)
		set(antice_probe_l_h,1)
		set(antice_probe_r_h,1)
		set(oxigen_ox, 1)
		set(electr_apugen_h, 1)
		set(aircond_airsource, 1)
		set(nws_h, 1)
		set(electr_apugen_h , 1)
		set(electr_gen_r_h , 1)
		set(electr_gen_l_h , 1)
		set(electr_stbi_h , 1)

		set(fuel_xpump_r, 1)
		set(fuel_xpump_l, 1)
		set(bleed_air_mode, 1)
		set(bleed_xbleed_h, 1)
		set(bleed_apu_h, 1)
		set(en_but_run_l, 1)
		set(en_but_run_r, 1)
		set(pedestal_h, 1)
		set(gshldl_h, 1)
		set(gshldr_h, 1)
		set(cbp_h, 1)
		set(jalousie1, 1)
		set(jalousie2, 1)
		set(jalousie3, 1)
		set(jalousie4, 1)
		set(jalousie5, 1)
		set(jalousie6, 1)
		set(jalousie7, 1)
		set(jalousie8, 1)
		set(jalousie9, 1)
		set(jalousie10, 1)
		set(jalousie11, 1)
		set(jalousie12, 1)
		set(ground_sp_h, 1)
		set(aux_hpump_h,1)
		set(l_hpump_h,1)
		set(r_hpump_h,1)
		set(ptu_h,1)
		set(cablight_h, 1)
		set(strobe_h, 2)
		set(nav_h, 1)
		set(emeright_h, 1)
		set(smokebelts_h, 2)
		set(landlight1_h, 1)
		set(landlight2_h, 1)
		set(xap_taxilight_h, 2)
		set(gust_lock, 0)--]=]
--		commandBegin(apu_b_start)
		start_seq = 1
     end
     return 1
 end

 registerCommandHandler(fast_start, 1, faststartHandler);









function update()




if get(position_saving) > 0.5 then
	 if get(startup_running) < 0.5 then
		if rpm1 > 30 or rpm2 > 30 then
			   if get(flight_time) > 0 then
					if get(flight_time) < 1 then
							start_seq = 1
					end
			   end
		 end

	   end
end


--[=[
 if get(position_saving) > 0.5 then
   if get(startup_running) < 0.5 then
    if rpm2 > 30  then
         if get(flight_time) > 0 then
               if get(flight_time) < 10 then
	         if get(ground_speed) < 16 then
	          commandOnce(starter_2)
	       end
	    end
	 end
      end
   end
end
--]=]




--FAST START




if start_seq == 1 then
	if get(APU_N1_percent) < 1 then commandBegin(apu_b_start) end
	if get(APU_N1_percent) > 90 and get(ENGN_N1_R) < 10 then set(en_starter_r, 2) else set(en_starter_r, 1) end
	if get(ENGN_N1_R) > 15 and get(ENGN_N1_L) < 10 then set(en_starter_l, 2) else set(en_starter_l, 1) end
end
if get(ENGN_N1_L) > 20 and get(ENGN_N1_R) > 20 and get(APU_N1_percent) > 98 then start_seq = 0 end


if get(APU_N1_percent) > 10 and start_seq == 1 then commandEnd(apu_b_start) end









--[=[
if get(flight_time) > 0 and get(flight_time) < 1 then
--set(mastervol, 0)
  if get(position_saving) > 0.5 then
  set(park_brake, 0)
  end
  else
if get(flight_time) > 0 and get(flight_time) < 1 then
set(park_brake, 1)
end
end
--]=]
--if get(flight_time) > 1 and get(flight_time) < 2 then
--set(mastervol, 1)
--end


-- Position saving functions

local x, y, z = worldToLocal(tab["latitude"], tab["longitude"], tab["elevation"])

if get(flight_time) > 0.5 and get(flight_time) < 1 then
	set(floats_r, tab["floats"])
	set(floats, tab["floats"])
	set(floats_rq, tab["floats"])
	set(sound_vol, tab["soundvol"])
	set(sound_mute, tab["soundmute"])


	if get(position_saving) > 0.5 then
		set(park_brake_handle, tab["parkbrake"])
	set(park_brake, tab["parkbrake"])


	end
end


 if get(position_saving) > 0.5 then
   if get(flight_time) > 0 then
	if get(flight_time) < 1 then
	set(velocity_vx, tab["velocityvx"])
	set(velocity_vy, tab["velocityvy"])
	set(velocity_vz, tab["velocityvz"])
	set(engn_prop1, tab["engnprop1"])
	set(engn_prop2, tab["engnprop2"])
	set(engn_throt1, tab["engnthrot1"])
	set(engn_throt2, tab["engnthrot2"])
	set(ignition1, tab["ignition1"])
	set(ignition2, tab["ignition2"])
	set(fuelselector, tab["fuelselector"])
	set(eng1mixt, tab["eng1mixt"])
	set(eng2mixt, tab["eng2mixt"])
	set(bat1, tab["bat1"])
	set(bat2, tab["bat2"])
--	set(generator, tab["generator"])
	set(avionics_power, tab["avionicspower"])
	set(paylweight, tab["paylweight"])
	set(propmode1, tab["propmode1"])
	set(propmode2, tab["propmode2"])
	set(propmode3, tab["propmode3"])
	set(propmode4, tab["propmode4"])
	set(propmode5, tab["propmode5"])
	set(propmode6, tab["propmode6"])
	set(propmode7, tab["propmode7"])
	set(propmode8, tab["propmode8"])
	set(en_but_run_l, tab["enbutrunl"])
	set(en_but_run_r, tab["enbutrunr"])
	set(APU_starter_switch, tab["apusw"])


	end
    end
 end




 if get(position_saving) > 0.5 then
    if get(flight_time) > 0 then
	if get(flight_time) < 1 then
		set(quater_1, tab["quater1"])
		set(quater_2, tab["quater2"])
		set(quater_3, tab["quater3"])
		set(quater_4, tab["quater4"])
		set(elevtrim, tab["elevtrim"])
		set(ailtrim, tab["ailtrim"])
		set(rudtrim, tab["rudtrim"])
		set(n1perc1, tab["n1perc1"])
		set(n1perc2, tab["n1perc2"])
		set(n2perc1, tab["n2perc1"])
		set(n2perc2, tab["n2perc2"])
	end
    end
 end


 if get(position_saving) > 0.5 then
    if get(flight_time) > 0 then
	if get(flight_time) < 1 then

		set(pos_x, x)
		set(pos_y, y)
		set(pos_z, z)

		set(livery, tab["livery"])

		set(avion_men, tab["avionmenu"])
		set(switch_1, tab["animationmenu"])
		set(switch_2, tab["leftupperdoor"])
		set(switch_3, tab["leftdowndoor"])
		set(switch_20, tab["switchesmenu"])
		set(switch_4, tab["rightdoor"])
		set(switch_5, tab["frontdoor"])
		set(switch_23, tab["insidefrontdoor"])
		set(switch_25, tab["toiletdoor"])
		set(switch_7, tab["enghoodleft"])
		set(switch_8, tab["enghoodright"])
		set(switch_14, tab["cockpitlight"])
		set(switch_15, tab["salonlight"])
		set(switch_16, tab["toiletlight"])
		set(switch_21, tab["hidepilot"])
		set(cop_hide, tab["hidecopilot"])
		set(switch_22, tab["touchscreen"])
		set(switch_25, tab["rightwindow"])
		set(switch_26, tab["leftwindow"])
		set(switch_6, tab["switch6"])
		set(tailhook, tab["tailhook"])
		set(camera_type, tab["cameratype"])




		set(gears_status2, tab["gearsdep1"])
		set(gears_status, tab["gearsdep1"])
		set(gears_dep_1, tab["gearsdep1"])
		set(gears_dep_2, tab["gearsdep2"])
		set(gears_dep_3, tab["gearsdep3"])

		set(livery, tab["livery"])
		set(autopilot, tab["autopilot"])

		set(autopilot, tab["autopilot"])
		set(aud_panel_pw, tab["audpanelpw"])
		set(comnav1_pw, tab["comnav1pw"])
		set(comnav2_pw, tab["comnav2pw"])
		set(gps_pw, tab["gpspw"])
		set(dme_power, tab["dmepower"])
		set(adf_power, tab["adfpower"])
		set(trans_mode, tab["transmode"])

		set(fueltank1, tab["fueltank1"])
		set(fueltank2, tab["fueltank2"])
		set(fueltank3, tab["fueltank3"])
		set(fueltank4, tab["fueltank4"])
		set(fueltank5, tab["fueltank5"])
		set(fueltank6, tab["fueltank6"])

		set(flaprat, tab["flaprat"])

		set(taxi_light, tab["taxilight"])
		set(nav_lights, tab["navlights"])
		set(wing_insp_h, tab["winginsph"])
		set(strobe, tab["strobe"])
		set(landlight1h, tab["landlight1h"])
		set(landlight2h, tab["landlight2h"])
		set(emeright_h, tab["emerighth"])

		set(jalousie1, tab["jalousie1"])
		set(jalousie2, tab["jalousie2"])
		set(jalousie3, tab["jalousie3"])
		set(jalousie4, tab["jalousie4"])
		set(jalousie5, tab["jalousie5"])
		set(jalousie6, tab["jalousie6"])

		set(jalousie7, tab["jalousie7"])
		set(jalousie8, tab["jalousie8"])
		set(jalousie9, tab["jalousie9"])
		set(jalousie10, tab["jalousie10"])
		set(jalousie11, tab["jalousie11"])
		set(jalousie12, tab["jalousie12"])

		set(table1, tab["table1"])
		set(table2, tab["table2"])
		set(table3, tab["table3"])
		set(table4, tab["table4"])

		set(pcush, tab["pcush"])

		set(headposx, tab["headposx"])
		set(headposy, tab["headposy"])
		set(headposz, tab["headposz"])
		set(headpsi, tab["headpsi"])
		set(headthe, tab["headthe"])
		set(mastervol, tab["mastervol"])
		set(smokebelts_h, tab["smokebeltsh"])

		set(sunscreen10, tab["sunscreen10"])
		set(sunscreen20, tab["sunscreen20"])
		set(sunscreen11, tab["sunscreen11"])
		set(sunscreen21, tab["sunscreen21"])

		set(cbp_h, tab["cbph"])
		set(gshldr_h, tab["gshldrh"])
		set(pedestal_h, tab["pedestalh"])
		set(gshldl_h, tab["gshldlh"])
		set(annun_h, tab["annunh"])
		set(dome_h, tab["domeh"])

		set(cmfd_h, tab["cmfdh"])
		set(cpfd_h, tab["cpfdh"])
		set(pmfd_h, tab["pmfdh"])
		set(ppfd_h, tab["ppfdh"])

		set(entrlight_h, tab["entrlighth"])
		set(cablight_h, tab["cablighth"])
		set(crewlit_h, tab["crewlith"])

	set(customslider1, tab["customslider1"])
	set(customslider1_r, tab["customslider1"])
	set(customslider2, tab["customslider2"])
	set(customslider2_r, tab["customslider2"])
	set(customslider3, tab["customslider3"])
	set(customslider3_r, tab["customslider3"])
	set(customslider4, tab["customslider4"])
	set(customslider4_r, tab["customslider4"])

	set(rembf1, tab["rembf1"])
	set(rembf2, tab["rembf2"])
	set(rembf3, tab["rembf3"])
	set(rembf4, tab["rembf4"])
	set(rembf5, tab["rembf5"])
	set(rembf6, tab["rembf6"])
	set(rembf7, tab["rembf7"])
	set(rembf8, tab["rembf8"])
	set(rembf9, tab["rembf9"])
	set(rembf10, tab["rembf10"])
	set(rembf11, tab["rembf11"])
	set(rembf12, tab["rembf12"])
	set(rembf13, tab["rembf13"])
	set(rembf14, tab["rembf14"])

	set(ground_sp_h, tab["groundsph"])

	set(electr_stbi_h, tab["electrstbih"])

	set(right_bat_h, tab["rightbath"])
    set(left_bat_h, tab["leftbath"])
	set(bus_tie_h, tab["bustieh"])
	set(electr_extp_h, tab["electrextph"])



	set(antice_wngsource_r, tab["anticewngsourcer"])
	set(antice_wshld_l_h, tab["anticewshldlh"])
	set(antice_wshld_r_h, tab["anticewshldrh"])
	set(antice_probe_l_h, tab["anticeprobelh"])
	set(antice_probe_r_h, tab["anticeproberh"])
	set(oxigen_ox, tab["oxigenox"])
	set(electr_apugen_h, tab["electrapugenh"])
	set(aircond_airsource, tab["aircondairsource"])
	set(nws_h, tab["nwsh"])
	set(electr_apugen_h , tab["electrapugenh"])
	set(electr_gen_r_h , tab["electrgenrh"])
	set(electr_gen_l_h , tab["electrgenlh"])
	set(fuel_xpump_r, tab["fuelxpumpr"])
	set(fuel_xpump_l, tab["fuelxpumpl"])
	set(bleed_air_mode, tab["bleedairmode"])
	set(bleed_xbleed_h, tab["bleedxbleedh"])
	set(bleed_apu_h, tab["bleedapuh"])
	set(en_but_run_l, tab["enbutrunl"])
	set(en_but_run_r, tab["enbutrunr"])
	set(aux_hpump_h, tab["auxhpumph"])
	set(l_hpump_h, tab["lhpumph"])
	set(r_hpump_h, tab["rhpumph"])
	set(ptu_h, tab["ptuh"])
	set(smokebelts_h, tab["smokebeltsh"])
	set(gust_lock, tab["gustlock"])











	end
    end
 end

-- Heading with anchor

--if get(flight_time) > 1 then
--if get(ralt_height) < 10 then
--if get(ground_speed) < 3 then
	--if get(park_brake) > 0.9 then
	--set(hd_position, 0)
		--if get(ground_speed) < 0.5 then
		--set(velocity_vx, 0)
		--set(velocity_vy, 0)
		--set(velocity_vz, 0)
		--end
	--end
    --end
--end
--end

-- save ini file


local tab = {}
tab["avionmenu"] = get(avion_men)
tab["animationmenu"] = get(switch_1)
tab["leftupperdoor"] = get(switch_2)
tab["leftdowndoor"] = get(switch_3)
tab["switchesmenu"] = get(switch_20)
tab["rightdoor"] = get(switch_4)
tab["frontdoor"] = get(switch_5)
tab["insidefrontdoor"] = get(switch_23)
tab["toiletdoor"] = get(switch_25)
tab["enghoodleft"] = get(switch_7)
tab["enghoodright"] = get(switch_8)
tab["cockpitlight"] = get(switch_14)
tab["salonlight"] = get(switch_15)
tab["toiletlight"] = get(switch_16)
tab["hidepilot"] = get(switch_21)
tab["touchscreen"] = get(switch_22)
tab["rightwindow"] = get(switch_25)
tab["leftwindow"] = get(switch_26)
tab["switch6"] = get(switch_6)
tab["tailhook"] = get(tailhook)
tab["cameratype"] = get(camera_type)
tab["elevation"] = get(elevation)
tab["longitude"] = get(longitude)
tab["latitude"] = get(latitude)
tab["gearsdep1"] = get(gears_dep_1)
tab["gearsdep2"] = get(gears_dep_2)
tab["gearsdep3"] = get(gears_dep_3)
tab["positionsaving"] = get(position_saving)
tab["vinet"] = get(vinet)
tab["parkbrake"] = get(park_brake)
tab["floats"] = get(floats_r)
tab["quater1"] = get(quater_1)
tab["quater2"] = get(quater_2)
tab["quater3"] = get(quater_3)
tab["quater4"] = get(quater_4)
tab["livery"] = get(livery)
tab["velocityvx"] =  get(velocity_vx)
tab["velocityvy"] =  get(velocity_vy)
tab["velocityvz"] =  get(velocity_vz)
tab["engnprop1"] = get(engn_prop1)
tab["engnprop2"] = get(engn_prop2)
tab["engnthrot1"] = get(engn_throt1)
tab["engnthrot2"] = get(engn_throt2)
tab["ignition1"] = get(ignition1)
tab["ignition2"] = get(ignition2)
tab["fuelselector"] = get(fuelselector)
tab["eng1mixt"] = get(eng1mixt)
tab["eng2mixt"] = get(eng2mixt)
tab["bat1"] = get(bat1)
tab["bat2"] = get(bat2)
tab["generator"] = get(generator)
tab["avionicspower"] = get(avionics_power)
tab["autopilot"] = get(autopilot)
tab["audpanelpw"] = get(aud_panel_pw)
tab["comnav1pw"] = get(comnav1_pw)
tab["comnav2pw"] = get(comnav2_pw)
tab["gpspw"] = get(gps_pw)
tab["dmepower"] = get(dme_power)
tab["adfpower"] = get(adf_power)
tab["transmode"] = get(trans_mode)
tab["fueltank1"] = get(fueltank1)
tab["fueltank2"] = get(fueltank2)
tab["fueltank3"] = get(fueltank3)
tab["fueltank4"] = get(fueltank4)
tab["fueltank5"] = get(fueltank5)
tab["fueltank6"] = get(fueltank6)
tab["proprot1"] = get(proprot1)
tab["proprot2"] = get(proprot2)
tab["flaprat"] = get(flaprat)
tab["taxilight"] = get(taxi_light)
tab["navlights"] = get(nav_lights)
tab["winginsph"] = get(wing_insp_h)
tab["hidecopilot"] = get(cop_hide)
tab["paylweight"] = get(paylweight)
tab["wavelimit"] = get(wave_limit_n)
tab["elevtrim"] = get(elevtrim)
tab["ailtrim"] = get(ailtrim)
tab["rudtrim"] = get(rudtrim)
tab["n1perc1"] = get(n1perc1)
tab["n1perc2"] = get(n1perc2)
tab["n2perc1"] = get(n2perc1)
tab["n2perc2"] = get(n2perc2)
tab["propmode1"] = get(propmode1)
tab["propmode2"] = get(propmode2)
tab["propmode3"] = get(propmode3)
tab["propmode4"] = get(propmode4)
tab["propmode5"] = get(propmode5)
tab["propmode6"] = get(propmode6)
tab["propmode7"] = get(propmode7)
tab["propmode8"] = get(propmode8)
tab["jalousie1"] = get(jalousie1)
tab["jalousie2"] = get(jalousie2)
tab["jalousie3"] = get(jalousie3)
tab["jalousie4"] = get(jalousie4)
tab["jalousie5"] = get(jalousie5)
tab["jalousie6"] = get(jalousie6)
tab["jalousie7"] = get(jalousie7)
tab["jalousie8"] = get(jalousie8)
tab["jalousie9"] = get(jalousie9)
tab["jalousie10"] = get(jalousie10)
tab["jalousie11"] = get(jalousie11)
tab["jalousie12"] = get(jalousie12)
tab["table1"] = get(table1)
tab["table2"] = get(table2)
tab["table3"] = get(table3)
tab["table4"] = get(table4)
tab["pcush"] = get(pcush)
tab["headposx"] = get(headposx)
tab["headposy"] = get(headposy)
tab["headposz"] = get(headposz)
tab["headpsi"] = get(headpsi)
tab["headthe"] = get(headthe)
tab["mastervol"] = get(mastervol)
tab["smokebeltsh"] = get(smokebelts_h)
tab["sunscreen10"] = get(sunscreen10)
tab["sunscreen20"] = get(sunscreen20)
tab["sunscreen11"] = get(sunscreen11)
tab["sunscreen21"] = get(sunscreen21)
tab["cbph"] = get(cbp_h)
tab["gshldrh"] = get(gshldr_h)
tab["pedestalh"] = get(pedestal_h)
tab["gshldlh"] = get(gshldl_h)
tab["annunh"] = get(annun_h)
tab["domeh"] = get(dome_h)
tab["cmfdh"] = get(cmfd_h)
tab["cpfdh"] = get(cpfd_h)
tab["pmfdh"] = get(pmfd_h)
tab["ppfdh"] = get(ppfd_h)
tab["strobe"] = get(strobe)
tab["landlight1h"] = get(landlight1h)
tab["landlight2h"] = get(landlight2h)
tab["emerighth"] = get(emeright_h)
tab["entrlighth"] = get(entrlight_h)
tab["cablighth"] = get(cablight_h)
tab["crewlith"] = get(crewlit_h)
tab["customslider1"] = get(customslider1)
tab["customslider2"] = get(customslider2)
tab["customslider3"] = get(customslider3)
tab["customslider4"] = get(customslider4)
tab["rembf1"] = get(rembf1)
tab["rembf2"] = get(rembf2)
tab["rembf3"] = get(rembf3)
tab["rembf4"] = get(rembf4)
tab["rembf5"] = get(rembf5)
tab["rembf6"] = get(rembf6)
tab["rembf7"] = get(rembf7)
tab["rembf8"] = get(rembf8)
tab["rembf9"] = get(rembf9)
tab["rembf10"] = get(rembf10)
tab["rembf11"] = get(rembf11)
tab["rembf12"] = get(rembf12)
tab["rembf13"] = get(rembf13)
tab["rembf14"] = get(rembf14)
tab["groundsph"] = get(ground_sp_h)
tab["enbutrunl"] = get(en_but_run_l)
tab["enbutrunr"] = get(en_but_run_r)
tab["electrstbih"] = get(electr_stbi_h)
tab["apusw"] = get(APU_starter_switch)
tab["rightbath"] = get(right_bat_h)
tab["leftbath"] = get(left_bat_h)
tab["bustieh"] = get(bus_tie_h)
tab["electrextph"] = get(electr_extp_h)
tab["soundvol"] = get(sound_vol)
tab["soundmute"] = get(sound_mute)

tab["anticewngsourcer"] =	get(antice_wngsource_r)
tab["anticewshldlh"] =	get(antice_wshld_l_h)
tab["anticewshldrh"] =	get(antice_wshld_r_h)
tab["anticeprobelh"] =	get(antice_probe_l_h)
tab["anticeproberh"] =	get(antice_probe_r_h)
tab["oxigenox"] =	get(oxigen_ox)
tab["electrapugenh"] =	get(electr_apugen_h)
tab["aircondairsource"] =	get(aircond_airsource)
tab["nwsh"] =	get(nws_h)
tab["electrapugenh"] =	get(electr_apugen_h )
tab["electrgenrh"] =	get(electr_gen_r_h)
tab["electrgenlh"] =	get(electr_gen_l_h)
tab["fuelxpumpr"] =	get(fuel_xpump_r)
tab["fuelxpumpl"] =	get(fuel_xpump_l)
tab["bleedairmode"] =	get(bleed_air_mode)
tab["bleedxbleedh"] =	get(bleed_xbleed_h)
tab["bleedapuh"] =	get(bleed_apu_h)
tab["enbutrunl"] =	get(en_but_run_l)
tab["enbutrunr"] =	get(en_but_run_r)
tab["auxhpumph"] =	get(aux_hpump_h)
tab["lhpumph"] =	get(l_hpump_h)
tab["rhpumph"] =	get(r_hpump_h)
tab["ptuh"] =	get(ptu_h)
tab["smokebeltsh"] =	get(smokebelts_h)
tab["gustlock"] =	get(gust_lock)

if get(flight_time) > 5 then
if get(local_time_sec) == 29 or get(local_time_sec) == 44 or get(local_time_sec) == 59 or get(local_time_sec) == 14 or position_saving_last ~= get(position_saving) or park_brake_last ~= get(park_brake) then
  if vinet_last ~= get(vinet) or anim_menu ~= get(switch_1) or switch_menu ~= get(switch_20) or hide_pilot ~= get(switch_21) or hide_touch ~= get(switch_22) or toil_light ~= get(switch_16) or salon_light ~= get(switch_15) or cock_light ~= get(switch_14) or toil_door ~= get(switch_24) or in_fr_door ~= get(switch_23) or r_window ~= get(switch_25) or l_window ~= get(switch_26) or r_engn_hood ~= get(switch_8) or l_engn_hood ~= get(switch_7) or water_rud ~= get(tailhook) or fr_door ~= get(switch_5) or r_door ~= get(switch_4) or l_up_door ~= get(switch_2) or l_dn_door ~= get(switch_3) or camera_last ~= get(camera_type) or elevation_last ~= get(elevation) or longitude_last ~= get(longitude) or latitude_last ~= get(latitude) or gears_dep_1_last ~= get(gears_dep_1) or gears_dep_2_last ~= get(gears_dep_2) or gears_dep_3_last ~= get(gears_dep_3) or floats_dep_last ~= get(floats_r) or quater_1_last ~= get(quater_1) or quater_2_last ~= get(quater_2) or quater_3_last ~= get(quater_3) or quater_4_last ~= get(quater_4) or livery_last ~= get(livery) then
	local filename = panelDir .. "/settings.ini"
	local savefile = io.open(filename, "w")
	for k, v in pairs(tab) do savefile:write(k," = ",v,"\n") end
	savefile:close()

	 vinet_last = get(vinet)
	 anim_menu = get(switch_1)
	 switch_menu = get(switch_20)
	 hide_pilot = get(switch_21)
	 hide_touch = get(switch_22)
	 toil_light =  get(switch_16)
	 salon_light =  get(switch_15)
	 cock_light = get(switch_14)
	 toil_door = get(switch_24)
	 in_fr_door = get(switch_23)
	 r_window = get(switch_25)
	 l_window = get(switch_26)
	 left_eng_hood_last = get(switch_7)
	 right_eng_hood_last = get(switch_8)
	 water_rud = get(tailhook)
	 fr_door = get(switch_5)
	 r_door = get(switch_4)
	 l_up_door = get(switch_2)
	 l_dn_door =  get(switch_3)
	 camera_last = get(camera_type)
	 elevation_last = get(elevation)
	 longitude_last = get(longitude)
	 latitude_last = get(latitude)
	 gears_dep_1_last = get(gears_dep_1)
	 gears_dep_2_last = get(gears_dep_2)
	 gears_dep_3_last = get(gears_dep_3)
	 floats_dep_last = get(floats_r)
	 quater_1_last = get(quater_1)
	 quater_2_last = get(quater_2)
	 quater_3_last = get(quater_3)
	 quater_4_last = get(quater_4)
	 floats_last = get(floats_r)
	 park_brake_last = get(park_brake)
	 position_saving_last = get(position_saving)
	 livery_last = get(livery)
	end
      end
   end

 last_states = {start_seq}
end
