defineProperty("poweron_start",globalProperty("giv_dataref/poweron_start")) 
defineProperty("batteries_on",globalProperty("giv_dataref/batteries_on")) 
defineProperty("gamepaused",globalProperty("sim/time/paused")) 
defineProperty("power_on1",globalProperty("sim/cockpit2/electrical/battery_on[0]")) 
defineProperty("power_on2",globalProperty("sim/cockpit2/electrical/battery_on[1]")) 
local criticalActionOccur = false

function update()


	if ((get(power_on1) == 1 or get(power_on2) == 1) and not criticalActionOccur) then
		set (poweron_start, 1) --no loop
		criticalActionOccur = true
		else
	set(poweron_start, 0)
	end

	if get(power_on1) == 0 and get(power_on2) == 0 then
		criticalActionOccur = false
	end
  
	if (get(power_on1) == 1 or get(power_on2) == 1) and get(gamepaused) == 0 then
		set (batteries_on, 1) --loop
	else
	  
	  set(batteries_on, 0)

	end
end