# Segnale di avviso fittizio da nascondere e collegare prima di un segnale
# di protezione per far suonare la Leopolder quando quest'ultimo si apre.
#
# Aspetti: nothing (non fa nulla), sound (suona se prima era nothing)

# Special pure distant to be placed hidden before a home signal; it plays a sound
# (a well known ringbell called 'Leopolder') whenever the next signal is cleared.
#
# Aspects: nothing   (do nothing, next signal is not clear)
#          sound     (play sound if previuos aspect was nothing)

# P.Rosati  04/07/2025 (Versione 6.0)

Aspect: nothing
	IconE: NN_b_E.xpm
	IconW: NN_b_W.xpm
	IconN: NN_b_N.xpm
	IconS: NN_b_S.xpm
	Action: none

Aspect: sound
	IconE: NN_b_E.xpm
	IconW: NN_b_W.xpm
	IconN: NN_b_N.xpm
	IconS: NN_b_S.xpm
	Action: none

# initial aspect

OnInit:
	.aspect = nothing
end

# the player or a script cleared the signal

OnCleared:
	return
end

# this or another signal changed its aspect

OnUpdate:
    do play Ding
	# Se segue un segnale di protezione... - If a home signal follows...
	if next.script > "rfi_prot"	and next.script < "rfi_prou"
		# Se il segnale è chiuso si prepara a suonare
		# If the signal is unclear, prepare to sound
		if next.aspect = red or next.aspect = shunt or next.color = white or next.aspect = off or next.aspect = disabled or next.aspect = fault
			.aspect = nothing
		else
			# Se il segnale si sta aprendo, suona; se è già aperto, non fa nulla
			# If the signal is clearing, sound; if it's already clear, do nothing
			if .aspect = nothing
			end
			.aspect = sound
		end
	end
end

# a train passed the signal

OnCross:
	return
end
