function generator_sound() end
generator_sound = create_dataref("giv_dataref/generator_sound","number",generator_sound1)
gen1_on = find_dataref("sim/cockpit2/electrical/generator_on[0]")
gen1_n2 = find_dataref("sim/flightmodel/engine/ENGN_N2_[0]")
gen2_on = find_dataref("sim/cockpit2/electrical/generator_on[1]")
gen2_n2 = find_dataref("sim/flightmodel/engine/ENGN_N2_[1]")
gen3_on = find_dataref("sim/cockpit2/electrical/APU_generator_on")
gen3_n2 = find_dataref("sim/cockpit2/electrical/APU_N1_percent")

if (gen3_on == 1 or gen2_on == 1 or gen1_on == 1) then
	generator_was_on = 1
	generator_sound = 0
else
	generator_was_on = 0
	generator_sound = 0
end
	

function before_physics()
	if gen1_n2 < 40 then
		gen1_on = 0
	end
	if gen2_n2 < 40 then
		gen2_on = 0
	end
	if gen3_n2 < 75 then
		gen3_on = 0
	end
	if (gen3_on == 1 or gen2_on == 1 or gen1_on == 1) then
		if (generator_sound == 0 and generator_was_on == 0) then
			generator_sound = 1
			generator_was_on = 1
		end
	end
	if (gen3_on == 0 and gen2_on == 0 and gen1_on == 0) then
			generator_sound = 0
			generator_was_on = 0
			
	end
end