function poweron_start1() end
poweron_start = create_dataref("giv_dataref/poweron_start","number",poweron_start1)
function batteries_on1() end
batteries_on = create_dataref("giv_dataref/batteries_on","number",batteries_on1) 
gamepaused = find_dataref("sim/time/paused") 
power_on1 = find_dataref("sim/cockpit2/electrical/battery_on[0]")
power_on2 = find_dataref("sim/cockpit2/electrical/battery_on[1]")
if (power_on1 == 1 or power_on2 == 1) then
	poweron_start_was = 1
	batteries_on_was = 1
	batteries_on = 1
	else
	poweron_start = 0
	batteries_on = 0
	poweron_start_was = 0
	batteries_on_was = 0
end
	

function after_physics()


	if (power_on1 == 1 or power_on2 == 1) and poweron_start_was == 0 then
		poweron_start = 1
		poweron_start_was = 1
	end

	if power_on1 == 0 and power_on2 == 0 and poweron_start_was == 1 then
		poweron_start = 0
		poweron_start_was = 0
	end
  
	if (power_on1 == 1 or power_on2 == 1) and gamepaused == 0 then
		batteries_on = 1
	else
		batteries_on = 0
	end
end