# Segnale di avviso seguito da protezione specifica per PL con barriere.
# NON nasconde ai segnali precedenti l'aspetto del segnale imperativo
# che segue, quindi il suo aspetto e la sua distanza da questo avviso
# influiranno sull'aspetto dei segnali precedenti. Versione grande.
#
# Aspetti: G  (PL aperto, il segnale precedente 'vede' G e considera la distanza)
#          GG (PL aperto, il segnale precedente 'vede' GG)
#          V  (PL chiuso, il segnale precedente 'vede' V)
#          D  (segnale del PL spento, il segnale precedente 'vede' un guasto)

# Pure distant specific for level crossings with gates, to be followed by
# an LC protection signal. This signal doesn't mask the aspect of the main
# signal that follows, so its aspect and its distance from this distant are
# considered by the previuos signals to determine their aspect. Bigger version.
#
# Aspects: Y  (LC gates open,   previous signal 'sees' Y and considers distance),
#          YY (LC gates open,   previous signal 'sees' YY),
#          G  (LC gates closed, previuos signal 'sees' G)
#          D  (LC signal unlit, previuos signal 'sees' a fault)

# P.Rosati  21/01/2021 (Versione 5.1)

Aspect: yellow
	IconE: LT_y_big_E.xpm
	IconW: LT_y_big_W.xpm
	IconN: LT_y_big_N.xpm
	IconS: LT_y_big_S.xpm
	Action: none

Aspect: short_yellow
	IconE: LT_y_big_E.xpm
	IconW: LT_y_big_W.xpm
	IconN: LT_y_big_N.xpm
	IconS: LT_y_big_S.xpm
	Action: none

Aspect: yellow_yellow
	IconE: LT_y_big_E.xpm
	IconW: LT_y_big_W.xpm
	IconN: LT_y_big_N.xpm
	IconS: LT_y_big_S.xpm
	Action: none

Aspect: green
	IconE: LT_g_big_E.xpm
	IconW: LT_g_big_W.xpm
	IconN: LT_g_big_N.xpm
	IconS: LT_g_big_S.xpm
	Action: none

Aspect: disabled
	IconE: LT_b_big_E.xpm
	IconW: LT_b_big_W.xpm
	IconN: LT_b_big_N.xpm
	IconS: LT_b_big_S.xpm
	Action: none

# initial aspect

OnInit:
	if .nextLength < 600
		.aspect = yellow_yellow
	else
		if .nextLength < 1200
			.aspect = short_yellow
		else
			.aspect = yellow
		end
	end
end

# the player or a script cleared the signal

OnCleared:
	return
end

# this or another signal changed its aspect

OnUpdate:
	if next.aspect = closed
		.aspect = green
		return
	end
	# Si controllano vari aspetti, perché questo segnale può essere usato per mascherarne altri
	# Many aspects are checked, as this signal may be used also to mask other signals
	if next.aspect = clear_off or next.aspect = unclear_off or next.aspect = off or next.aspect = fault
		.aspect = disabled
		return
	end
	if next.aspect = clear_not_closed or next.aspect = unclear_not_closed or next.aspect = red or next.aspect = shunt or next.aspect = red_yellow_yellow or next.color = white
		if .nextLength < 600
			.aspect = yellow_yellow
		else
			if .nextLength < 1200
				.aspect = short_yellow
			else
				.aspect = yellow
			end
		end
	else
		.aspect = green
	end
end

# a train passed the signal

OnCross:
	return
end
