# Segnale alto di manovra (imperativo). Se spento si apre solo con Ctrl-Click.
#
# Aspetti: ­ (red), | (shunt), spento (off), guasto (fault)

# Standalone shunting signal (tall). When unlit clears only with Ctrl-click.
#
# Aspects: - (red), | (shunt), off, fault

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

Aspect: red
	IconE: SM_-_E.xpm
	IconW: SM_-_W.xpm
	IconN: SM_-_N.xpm
	IconS: SM_-_S.xpm
	Action: stop

Aspect: off
	IconE: SM___E.xpm
	IconW: SM___W.xpm
	IconN: SM___N.xpm
	IconS: SM___S.xpm
	Action: stop

Aspect: fault
	IconE: SM___E.xpm
	IconW: SM___W.xpm
	IconN: SM___N.xpm
	IconS: SM___S.xpm
	Action: speedLimit 30

Aspect: shunt
	IconE: SM_I_E.xpm
	IconW: SM_I_W.xpm
	IconN: SM_I_N.xpm
	IconS: SM_I_S.xpm
	Action: speedLimit 29

# initial aspect

OnInit:
	.aspect = red
end

# the player or a script cleared the signal

OnCleared:
	# Se bloccato, spento o seguito da un segnale guasto superabile, si apre solo con Ctrl-click
	# If blocked, unlit or followed by a passable faulty signal, clears only with Ctrl-click
	if .aspect ! off and next.aspect ! fault and next.aspect ! block
		.aspect = shunt
	end
end

# this or another signal changed its aspect

OnUpdate:
	# Se è aperto e segue un segnale guasto superabile, si chiude
	# If clear but a passable faulty signal follows, unclears
	if .aspect = shunt and next.aspect = fault
		.click = 1
	end
end

# the player or a script cleared the signal for shunting

OnShunt:
	if .aspect = off
		.aspect = fault
	else
		.aspect = shunt
	end
end

# a train passed the signal

OnCross:
	if .aspect = fault
		.aspect = off
	else
		.aspect = red
	end
end

# the player or a script uncleared the signal

OnUncleared:
	if .aspect = fault
		.aspect = off
	else
		.aspect = red
	end
end
