'##############
'Cockpit-Script
'##############

'Simuliert alle unmittelbar mit dem Armaturenbrett zusammenhängenden Funktionen

'(c) 23.10.2009 Rüdiger Hülsmann
'(c) 01.11.2012 Marcel Kuhnt
'(c) 27.02.2011 Markus Rabe

'Script Version: 1.0
'Omsi release: 1.0

'Needs:
'- antrieb
'- engine
'- bremse
'- lights
'- wiper?
'- doors


'Revision History:
'- Rüdiger Hülsmann	09.06.2009	Last Change				
'- Marcel Kuhnt		13.06.2009	Added Gearbox switches			
'- Marcel Kuhnt		13.06.2009	Moved some switchvars to other scripts	
'- Rüdiger Hülsmann	19.06.2009	Added Openable Window Triggers
'- Rüdiger Hülsmann	23.10.2009	Added Battery and kinderwagen light
'- Marcel Kuhnt		26.10.2009	Radio switchable with Motorkühlung (replaced with cassette player)
'- Rüdiger Hülsmann	28.10.2009	Added driver door
'- Rüdiger Hülsmann	16.12.2009	Added driver curtain
'- Rüdiger Hülsmann	18.12.2009	Bugfix driver curtain
'- Marcel Kuhnt		15.04.2010	Traegheit debugged
'- Rüdiger Hülsmann	13.05.2010	Engine temperature
'- Rüdiger Hülsmann	03.06.2010	Automatic battery switch on key insertion (For standard-II-buses)
'- Rüdiger Hülsmann	08.06.2010	Automatic battery switch made optional, Auxiliary heating switchable by button or switch
'- Rüdiger Hülsmann	23.06.2010	Added mouse-clickable wiper lever on wheel console
'- Rüdiger Hülsmann	08.07.2010	Wiper lever: Improved usability 
'- Rüdiger Hülsmann	18.07.2010	Wiper lever: soundfix for keyboard operation and new ignition key algorithm 
'- Rüdiger Hülsmann	16.09.2010	Auxheat Switch Bugfix
'- Rüdiger Hülsmann	18.09.2010	Imported microphone switch
'- Rüdiger Hülsmann	17.10.2010	Added pressure warning needle
'- Rüdiger Hülsmann	23.10.2010	Added old-style gear button functionality
'- Rüdiger Hülsmann	06.11.2010	Gear-button "1" functionality removed for old-style gear buttons
'- Rüdiger Hülsmann	16.11.2010	Heating sliders
'- Rüdiger Hülsmann	23.11.2010	Central lubrication, cabin heater sound
'- Rüdiger Hülsmann	23.12.2010	Included 10 "multi-purpose" dummy switches
'- Rüdiger Hülsmann	29.12.2010	ASR switch
'- Rüdiger Hülsmann	04.01.2011	"D-only" gear selector function
'- Rüdiger Hülsmann	05.01.2011	fog lamp switch, high beam lever animation, clock debugged
'- Rüdiger Hülsmann	07.01.2011	Wiper lever sound and function debugges, availybility of several cockpit functions depending on bus type (via constfile)
'- Rüdiger Hülsmann	16.01.2011	Support for wiper turn-switch
'- Rüdiger Hülsmann	18.01.2011	Old-style gear button sounds
'- Rüdiger Hülsmann	26.01.2011	Invertable driver door
'- Rüdiger Hülsmann	26.01.2011	Thermometer
'- Markus Rabe		27.02.2011	Heizlüfter und Wagenheizung Motorabhängig, Leuchtmelder Hintertür an 80er D Wagen angepasst
'- Marcel Kuhnt		25.06.2011	Nebelscheinwerfer-Schalter (cp_licht_nebelschw_sw)
'- Marcel Kuhnt		29.06.2011	Türkontrolle für D92 und D86 integriert
'- Marcel Kuhnt		22.06.2012	Uhr läuft nur, wenn Strom vorhanden
'- Marcel Kuhnt		09.07.2012	Busbar wird als Faktor/Spannung interpretiert
'- Marcel Kuhnt		25.07.2012	Stromverbrauch, Generierung von Leitwert
'- Marcel Kuhnt		01.11.2012	Türentriegelungs-Leuchtmelder
'- Maerkertram		2015		Diverse Änderungen für das Addon X10 Berlin

'------------------------------------------------------------------------------------------


'----------------------
'    Trigger
'----------------------

{trigger:Amartur_verschieben_drag}
  (L.L.elec_busbar_main)
  {if}
    (L.S.mouse_x) abs (L.S.mouse_y) abs >= 
    {if}
      (L.S.mouse_x) 200 / (L.L.Amartur_rot) + -1 max 1 min (S.L.Amartur_rot)
    {else}
      (L.S.mouse_y) 200 / (L.L.Amartur_trans) + -1 max 1 min (S.L.Amartur_trans)
    {endif}
  {endif}
{end}

{trigger:automatic_R}
	(L.L.antrieb_getr_gangvorwahl) 1 <= 
	{if}
		(L.L.antrieb_getr_gangvorwahl) 0 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		
		0 (S.L.antrieb_getr_gangvorwahl)
			
		1 (S.L.cockpit_gangR)
	{endif}
{end}

{trigger:automatic_R_off}
	(L.L.cockpit_gangR) 1 =
	{if}
		0.7 (S.L.cockpit_gangR)
	{endif}
{end}



{trigger:automatic_R_mouse}
	(L.L.antrieb_getr_gangvorwahl) 1 <= 
	{if}
		(L.L.antrieb_getr_gangvorwahl) 0 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		0 (S.L.antrieb_getr_gangvorwahl)
		1 (S.L.cockpit_gangR)
	{endif}
{end}

{trigger:automatic_R_mouse_off}
	(L.L.cockpit_gangR) 1 =
	{if}
		0.7 (S.L.cockpit_gangR)
	{endif}
{end}


{trigger:automatic_N}
	(L.L.antrieb_getr_gangvorwahl) 1 = !
		{if}
			(T.L.ev_gangwahltaster_N)
			(L.S.getTime) (C.L.antrieb_gangwahlzeit) (C.L.antrieb_neutralwahlzeit) -  - (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
	1 (S.L.antrieb_getr_gangvorwahl) (S.L.cockpit_gangN)
	0 (S.L.cockpit_gangR) (S.L.cockpit_gang1) (S.L.cockpit_gang2) (S.L.cockpit_gang3)
{end}


{trigger:automatic_N_off}
		0 (S.L.cockpit_gangN)
{end}


{trigger:automatic_1}
	(L.L.antrieb_getr_gangvorwahl) 0 >
	(C.L.cockpit_gear_D_only) ! &&
	{if}
		(L.L.antrieb_getr_gangvorwahl) 2 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		2 (S.L.antrieb_getr_gangvorwahl)
		1 (S.L.cockpit_gang1)
		0 (S.L.cockpit_gang2) (S.L.cockpit_gang3)
	{endif}
{end}


{trigger:automatic_1_off}
	(L.L.cockpit_gang1) 1 =
	{if}
		0.7 (S.L.cockpit_gang1)
	{endif}
{end}


{trigger:automatic_2}
	(L.L.antrieb_getr_gangvorwahl) 0 >
	(C.L.cockpit_gear_D_only) ! &&
	{if}
		(L.L.antrieb_getr_gangvorwahl) 3 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		3 (S.L.antrieb_getr_gangvorwahl)
		1 (S.L.cockpit_gang2)
		0 (S.L.cockpit_gang1) (S.L.cockpit_gang3)
	{endif}
{end}


{trigger:automatic_2_off}
	(L.L.cockpit_gang2) 1 =
	{if}
		0.7 (S.L.cockpit_gang2)
	{endif}
{end}


{trigger:automatic_D}
	(L.L.antrieb_getr_gangvorwahl) 0 >
	{if}
		(L.L.antrieb_getr_gangvorwahl) 4 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		4 (S.L.antrieb_getr_gangvorwahl)
		1 (S.L.cockpit_gang3)
		0 (S.L.cockpit_gang1) (S.L.cockpit_gang2)	
	{endif}
{end}


{trigger:automatic_D_off}
	(L.L.cockpit_gang3) 1 =
	{if}
		0.7 (S.L.cockpit_gang3)
	{endif}	
{end}


{trigger:automatic_r-frei}
	1 (S.L.cockpit_gang_r-frei)
	(L.L.cockpit_gangR_toggle) (L.L.cockpit_gang2_toggle) ! (L.L.cockpit_gang3_toggle) ! && &&
	{if}
		(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		0 (S.L.antrieb_getr_gangvorwahl)
	{endif}
{end}

{trigger:automatic_r-frei_off}
	0 (S.L.cockpit_gang_r-frei)
{end}
	

{trigger:horn}
	
		(L.L.cockpit_hupe) ! (L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
		{if}
			(T.L.ev_hupe_an)
		{endif}
		1 (S.L.cockpit_hupe)
	
{end}

{trigger:horn_off}	
	
		(L.L.cockpit_hupe) (L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
		{if}
			(T.L.ev_hupe_aus)
		{endif}
		0 (S.L.cockpit_hupe)	
	
{end}

{trigger:cp_retarder_direkt_toggle}
	(L.L.cp_retarder_sw_direkt) ! (S.L.cp_retarder_sw_direkt) s1
	(M.L.wippschaltersound)
{end}


{trigger:cp_retarder_toggle}
	(C.L.cockpit_has_retarderswitch)
	{if}
		(L.L.cp_retarder_sw) ! (S.L.cp_retarder_sw) s1
		(M.L.wippschaltersound)
	{endif}
{end}

{trigger:cp_motorkuehlung_toggle}
	(C.L.cockpit_has_coolingswitch)
	{if}
		(L.L.cp_motorkuehlung_sw) ! (S.L.cp_motorkuehlung_sw) s1
		(M.L.wippschaltersound)
	{endif}
{end}

{trigger:cp_fahrerlicht_toggle}
	(L.L.cp_fahrerlicht_sw) ! (S.L.cp_fahrerlicht_sw) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_licht_untenrechts_toggle}
	(L.L.cp_licht_unterdeck_sw) -1 =
	{if}
		0 (S.L.cp_licht_unterdeck_sw) s1
	{else}
		-1 (S.L.cp_licht_unterdeck_sw) s1
	{endif}		
	(M.L.wippschaltersound)
{end}

{trigger:cp_licht_oberdeck_toggle}
	(L.L.cp_licht_oberdeck_sw) 
	{if}
		0 (S.L.cp_licht_oberdeck_sw) s1
	{else}
		1 (S.L.cp_licht_oberdeck_sw) s1
	{endif}		
	(M.L.wippschaltersound)
{end}

{trigger:cp_licht_unterdeck_toggle}
	(L.L.cp_licht_unterdeck_sw) 1 =
	{if}
		0 (S.L.cp_licht_unterdeck_sw) s1
	{else}
		1 (S.L.cp_licht_unterdeck_sw) s1
	{endif}		
	(M.L.wippschaltersound)
{end}

{trigger:cp_heizluefter_toggle}
	(L.L.cp_heizluefter_sw) ! (S.L.cp_heizluefter_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_spiegelheizung_toggle}
	(L.L.cp_spiegelheizung_sw) ! (S.L.cp_spiegelheizung_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_tuerfluegelsperre_links}
	(L.L.cp_tuerfluegelsperre_sw) 0 =
	{if}
		-1 (S.L.cp_tuerfluegelsperre_sw)
		(T.L.ev_kippschalter_ein)
	{else}
	(L.L.cp_tuerfluegelsperre_sw) 1 =
	{if}
		0 (S.L.cp_tuerfluegelsperre_sw)
		(T.L.ev_kippschalter_aus)
	{endif}
	{endif}
{end}

{trigger:cp_schalter_tuerfluegelsperre_rechts}
	(L.L.cp_tuerfluegelsperre_sw) 0 =
	{if}
		1 (S.L.cp_tuerfluegelsperre_sw)
		(T.L.ev_kippschalter_ein)
	{else}
	(L.L.cp_tuerfluegelsperre_sw) -1 =
	{if}
		0 (S.L.cp_tuerfluegelsperre_sw)
		(T.L.ev_kippschalter_aus)
	{endif}
	{endif}
{end}


{trigger:cp_dummy_sw01_toggle}
	(L.L.cp_dummy_sw01) ! (S.L.cp_dummy_sw01) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_dummy_sw02_toggle}
	(L.L.cp_dummy_sw02) ! (S.L.cp_dummy_sw02) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_dummy_sw03_toggle}
	(L.L.cp_dummy_sw03) ! (S.L.cp_dummy_sw03) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_dummy_sw04_toggle}
	(L.L.cp_dummy_sw04) ! (S.L.cp_dummy_sw04) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_dummy_sw05_toggle}
	(L.L.cp_dummy_sw05) ! (S.L.cp_dummy_sw05) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_dummy_sw06_toggle}
	(L.L.cp_dummy_sw06) ! (S.L.cp_dummy_sw06) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_dummy_sw07_toggle}
	(L.L.cp_dummy_sw07) ! (S.L.cp_dummy_sw07) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_dummy_sw08_toggle}
	(L.L.cp_dummy_sw08) ! (S.L.cp_dummy_sw08) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_dummy_sw09_toggle}
	(L.L.cp_dummy_sw09) ! (S.L.cp_dummy_sw09) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_dummy_sw10_toggle}
	(L.L.cp_dummy_sw10) ! (S.L.cp_dummy_sw10) s1
	(M.L.wippschaltersound)
{end}

{trigger:cp_schalter_ASR_off_toggle}
	(L.L.cp_ASR_off) ! (S.L.cp_ASR_off) s1
	(M.L.wippschaltersound)
{end}




{trigger:cp_rollo_drag}

	(L.L.cp_rollo_pos) (S.L.cp_rollo_lastpos)

	1 (S.L.cp_rollo_dragged)
	0 (S.L.cp_rollo_speed)
	(L.S.mouse_y) 500 / (L.L.cp_rollo_pos) + (S.L.cp_rollo_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_rollo_pos)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_rollo_pos)
	{endif}

	(L.L.cp_rollo_pos) (L.L.cp_rollo_lastpos) - abs (L.S.Timegap) / (S.L.cp_rollo_speed)

{end}

{trigger:cp_rollo_off}
	0 (S.L.cp_rollo_dragged)
	(T.L.ev_rollo_end)
{end}

{trigger:cp_rollo_retract}
	(L.L.cp_rollo_bommel) 0 = (L.L.cp_rollo_pos) &&
	{if}
		(T.L.ev_rollo_retract)
	{endif}
	1 (S.L.cp_rollo_bommel) (S.L.cp_rollo_retract)

{end}

{trigger:cp_rollo_retract_off}
	0 (S.L.cp_rollo_bommel) (S.L.cp_rollo_retract) (S.L.cp_rollo_speed)
{end}

'Fahrerrollo***

{trigger:cp_rolloF_drag}

	(L.L.cp_rolloF_pos) (S.L.cp_rolloF_lastpos)

	1 (S.L.cp_rolloF_dragged)
	0 (S.L.cp_rolloF_speed)
	(L.S.mouse_y) 500 / (L.L.cp_rolloF_pos) + (S.L.cp_rolloF_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_rolloF_pos)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_rolloF_pos)
	{endif}

	(L.L.cp_rolloF_pos) (L.L.cp_rolloF_lastpos) - abs (L.S.Timegap) / (S.L.cp_rolloF_speed)

{end}

{trigger:cp_rolloF_off}
	0 (S.L.cp_rolloF_dragged)
	(T.L.ev_rolloF_end)
{end}

{trigger:cp_rolloF_retract}
	(L.L.cp_rolloF_bommel) 0 = (L.L.cp_rolloF_pos) &&
	{if}
		(T.L.ev_rolloF_retract)
	{endif}
	1 (S.L.cp_rolloF_bommel) (S.L.cp_rolloF_retract)

{end}

{trigger:cp_rolloF_retract_off}
	0 (S.L.cp_rolloF_bommel) (S.L.cp_rolloF_retract) (S.L.cp_rolloF_speed)
{end}



{trigger:cp_fahrerfenster_opn_drag}

	(L.L.cp_fahrerfenster_pos) (S.L.cp_fahrerfenster_lastpos)

	(L.S.mouse_x) -500 / (L.L.cp_fahrerfenster_pos) + (S.L.cp_fahrerfenster_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fahrerfenster_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fahrerfenster_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.cp_fahrerfenster_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.cp_fahrerfenster_pos) (L.L.cp_fahrerfenster_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}


{trigger:cp_fahrerfenster_opn_off}
	0 (S.L.cp_fahrerfenster_speed)
{end}


{trigger:cp_schluessel_mov_drag}

'	Ein-/Ausstecken nur erlauben, wenn Schlüssel(dreh)stellung auf 0
	
	(L.L.cp_schluessel_rot_mode) 0 =
	{if}

'		Translation (Einstecken)

		(L.S.mouse_x) -20 / (L.L.cp_schluessel_trans) + 0 max 1 min (S.L.cp_schluessel_trans) s0
		
'		Stufen:
'		0: Schlüssel abgezogen
'		1: Schlüssel eingesteckt

		l0 0.5 > (S.L.cp_schluessel_trans_mode)
	{endif}

'	Drehen nur erlauben, wenn Schlüssel eingesteckt
	
	(L.L.cp_schluessel_trans_mode) 1 =
	{if}

'		Rotation (Drehen)

		(L.S.mouse_y) -100 / (L.L.cp_schluessel_rot) + 0 max 3 min (S.L.cp_schluessel_rot) s1

'		Stufen:
'		0: Nix
'		1: Standstellung, Elektrik an
'		2: Fahrstellung
'		3: Motorstart (springt zurück auf 2)

		l1 0.5 <=             {if} 0 (S.L.cp_schluessel_rot_mode) {endif}
		l1 0.5 > l1 1.5 <= && {if} 1 (S.L.cp_schluessel_rot_mode) {endif}
		l1 1.5 > l1 2.5 <= && {if} 2 (S.L.cp_schluessel_rot_mode) {endif}
		l1 2.5 >              {if} 3 (S.L.cp_schluessel_rot_mode) {endif}
	{endif}
{end}

{trigger:cp_schluessel_mov_off}
'	Einrasten auf den festen Positionen:
	(L.L.cp_schluessel_trans_mode) (S.L.cp_schluessel_trans)
	(L.L.cp_schluessel_rot_mode) 2 min (S.L.cp_schluessel_rot) (S.L.cp_schluessel_rot_mode)
{end}




{trigger:cp_lichtdreh_mov_drag}

'	Fallunterscheidung: Schalter in x- oder y-Richtung?
	
	(L.S.mouse_y) abs (L.S.mouse_x) abs >= 1
	{if}

'		Zunächst Translation (Rausziehen/Reindrücken)

		(L.S.mouse_y) 20 / (L.L.cp_lichtdreh_trans) + 0 max 2 min (S.L.cp_lichtdreh_trans) s0
		
'		Stufen:
'		0: Reingedrückt (Standard)
'		1: Halb rausgezogen (Nebelscheinwerfer)
'		2: Ganz rausgezogen (Nebelschlussleuchte)

		l0 0.5 <=             {if} 0 (S.L.cp_lichtdreh_trans_mode) {endif}
		l0 0.5 > l0 1.5 <= && {if} 1 (S.L.cp_lichtdreh_trans_mode) {endif}
		l0 1.5 >              {if} 2 (S.L.cp_lichtdreh_trans_mode) {endif}
	{else}

'		Sonst Rotation (Drehen)

		(L.S.mouse_x) 20 / (L.L.cp_lichtdreh_rot) + 0 max 2 min (S.L.cp_lichtdreh_rot) s1

'		Stufen:
'		0: Licht aus
'		1: Standlicht
'		2: Abblendlicht

		l1 0.5 <=             {if} 0 (S.L.cp_lichtdreh_rot_mode) {endif}
		l1 0.5 > l1 1.5 <= && {if} 1 (S.L.cp_lichtdreh_rot_mode) {endif}
		l1 1.5 >              {if} 2 (S.L.cp_lichtdreh_rot_mode) {endif}
	{endif}
{end}

{trigger:cp_lichtdreh_mov_off}
'	Einrasten auf den festen Positionen:
	(L.L.cp_lichtdreh_trans_mode) (S.L.cp_lichtdreh_trans)
	(L.L.cp_lichtdreh_rot_mode) (S.L.cp_lichtdreh_rot)
{end}

{trigger:cp_lichtdreh_rausziehen}
	(L.L.cp_lichtdreh_trans_mode) 1 + 2 min (S.L.cp_lichtdreh_trans_mode) (S.L.cp_lichtdreh_trans)
{end}

{trigger:cp_lichtdreh_reindruecken}
	(L.L.cp_lichtdreh_trans_mode) 1 - 0 max (S.L.cp_lichtdreh_trans_mode) (S.L.cp_lichtdreh_trans)
{end}

{trigger:cp_wiper_turnswitch_drag}
	
		(L.S.mouse_y) -50 / (L.L.cockpit_wischer_drehschalter) + 0 max 3 min (S.L.cockpit_wischer_drehschalter) s0
	
'		Stufen:
'		0: Aus
'		1: Intervall
'		2: Langsam
'		3: Schnell

		l0 0.5 <=             {if} 0 (S.L.cockpit_wischer_drehschalter_mode) {endif}
		l0 0.5 > l0 1.5 <= && {if} 1 (S.L.cockpit_wischer_drehschalter_mode) {endif}
		l0 1.5 > l0 2.5 <= && {if} 2 (S.L.cockpit_wischer_drehschalter_mode) {endif}
		l0 2.5 >              {if} 3 (S.L.cockpit_wischer_drehschalter_mode) {endif}

{end}

{trigger:cp_wiper_turnswitch_off}
'	Einrasten auf den festen Positionen:
	(L.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischer_drehschalter)
{end}

{trigger:kw_wipermode_up}
'	Wipermode up
	(L.L.cockpit_wischer_drehschalter_mode) 1 + 3 min (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischer_drehschalter)
{end}

{trigger:kw_wipermode_down}
'	Wipermode down
	(L.L.cockpit_wischer_drehschalter_mode) 1 - 0 max (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischer_drehschalter)
{end}

{trigger:cp_wischer_intervall_toggle}
'	Wipermode down (aus Kompatibilitätsgründen hier nochmal als "intervall"-Trigger / Shift+W)
	(L.L.cockpit_wischer_drehschalter_mode) 1 - 0 max (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischer_drehschalter)
{end}

{trigger:cp_wischer_wascher_button}
	1 (S.L.cp_wischer_wascher_sw)
	(T.L.ev_wischerhebel)
{end}

{trigger:cp_wischer_wascher_button_off}
	0 (S.L.cp_wischer_wascher_sw)
	(T.L.ev_wischerhebel)
{end}

{trigger:cp_lenkrad_toggle}
	(L.L.cp_lenkrad_visible) ! (S.L.cp_lenkrad_visible)
{end}


{trigger:cp_batterietrennschalter_toggle}
	(L.L.cp_schluessel_rot_mode) 0 =
	{if}
		1 (S.L.cp_schluessel_trans_mode) (S.L.cp_schluessel_trans)
		1 (S.L.cp_schluessel_rot_mode) (S.L.cp_schluessel_rot)
	{else}
	(L.L.engine_on) !
	{if}
		0 (S.L.cp_schluessel_rot_mode) (S.L.cp_schluessel_rot)
	{endif}
	{endif}
{end}



{trigger:cp_klappfenster_OR1}
	(L.L.cp_klappfenster_OR1) ! (S.L.cp_klappfenster_OR1) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OR2}
	(L.L.cp_klappfenster_OR2) ! (S.L.cp_klappfenster_OR2) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OR3}
	(L.L.cp_klappfenster_OR3) ! (S.L.cp_klappfenster_OR3) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OR4}
	(L.L.cp_klappfenster_OR4) ! (S.L.cp_klappfenster_OR4) s1
	(M.L.klappfenstersound)
{end}


{trigger:cp_klappfenster_OL1}
	(L.L.cp_klappfenster_OL1) ! (S.L.cp_klappfenster_OL1) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OL2}
	(L.L.cp_klappfenster_OL2) ! (S.L.cp_klappfenster_OL2) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OL3}
	(L.L.cp_klappfenster_OL3) ! (S.L.cp_klappfenster_OL3) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_OL4}
	(L.L.cp_klappfenster_OL4) ! (S.L.cp_klappfenster_OL4) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_UR1}
	(L.L.cp_klappfenster_UR1) ! (S.L.cp_klappfenster_UR1) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_UR2}
	(L.L.cp_klappfenster_UR2) ! (S.L.cp_klappfenster_UR2) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_UR3}
	(L.L.cp_klappfenster_UR3) ! (S.L.cp_klappfenster_UR3) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_UR4}
	(L.L.cp_klappfenster_UR4) ! (S.L.cp_klappfenster_UR4) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_UL1}
	(L.L.cp_klappfenster_UL1) ! (S.L.cp_klappfenster_UL1) s1
	(M.L.klappfenstersound)
{end}

{trigger:cp_klappfenster_UL2}
	(L.L.cp_klappfenster_UL2) ! (S.L.cp_klappfenster_UL2) s1
	(M.L.klappfenstersound)
{end}


{trigger:cp_Fahrertuer_drag}

	1 (S.L.cp_fahrertuer_dragged)
	(L.L.cp_fahrertuer_pos) (S.L.cp_fahrertuer_lastpos)

	(L.S.mouse_x) 500 / (L.L.cp_fahrertuer_pos) + (S.L.cp_fahrertuer_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_fahrertuer_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_fahrertuer_pos)
	{endif}

	(L.L.cp_fahrertuer_pos) (L.L.cp_fahrertuer_lastpos) - (L.S.Timegap) / (S.L.cp_fahrertuer_speed)
{end}


{trigger:cp_Fahrertuer_off}
	0 (S.L.cp_fahrertuer_dragged)
{end}



{trigger:KR_play}
	(L.L.cockpit_KR_play) 0.1 < 
	{if}
		(T.L.ev_kr_play)
	{endif}
	1 (S.L.cockpit_KR_play) (S.L.Snd_Radio)
{end}

{trigger:KR_play_off}
	0.8 (S.L.cockpit_KR_play)
{end}


{trigger:KR_stop}
	1 (S.L.cockpit_KR_stop)
	0 (S.L.cockpit_KR_play) (S.L.Snd_Radio)
	(T.L.ev_kr_stop)
{end}

{trigger:KR_stop_off}
	0 (S.L.cockpit_KR_stop)
{end}

	
{trigger:cp_microphone}
	1 (S.L.cp_microphone_sw)
{end}

{trigger:cp_microphone_off}
	0 (S.L.cp_microphone_sw)
{end}

' neue Trigger

{trigger:vdv_displaywechsel}
	1 (S.L.displaywechsel_sw) (S.L.vdv_mode_weiter)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:vdv_displaywechsel_off}
	0 (S.L.displaywechsel_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_kneel_up}
	1 (S.L.cp_kneel_sw)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_kneel_up_off}
	0 (S.L.cp_kneel_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_kneel_down}
	-1 (S.L.cp_kneel_sw)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_kneel_down_off}
	0 (S.L.cp_kneel_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_kamera}
	1 (S.L.cp_kamera_sw) (S.L.kamera_mode_weiter)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_kamera_off}
	0 (S.L.cp_kamera_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_kamera_off}
	0 (S.L.cp_kamera_sw)
	(T.L.ev_kippschalter_aus)
{end}

{trigger:cp_sprechwunsch}
	1 (S.L.cp_sprechwunsch_sw)
	(T.L.ev_kippschalter_ein)
{end}

{trigger:cp_sprechwunsch_off}
	0 (S.L.cp_sprechwunsch_sw)
	(T.L.ev_kippschalter_aus)
{end}


'----------------------
'	Init
'----------------------

{macro:cockpit_init}
	0 (S.L.cockpit_hupe_volume) (S.L.door_handsteuerung)
	1 (S.L.cp_retarder_sw) (S.L.cp_lenkrad_visible)
{end}

'----------------------
'	Frame
'----------------------
{macro:cockpit_frame}
'Übertragen der Schalterstellungen:
	(L.L.cp_retarder_sw) (S.L.antrieb_retarder_sw)
	(L.L.cp_retarder_sw_direkt) (S.L.antrieb_retarder_sw_direkt)
	(L.L.cp_wischer_wascher_sw) (S.L.wiper_wascher_sw)
	(L.L.cp_schluessel_trans_mode) 1 = (L.L.cp_schluessel_rot_mode) 1 >= && (S.L.elec_busbar_main_sw)

	(M.L.tacho_frame)
	(M.L.uhr_frame)
	(M.L.hupe_frame)
	(M.L.blinkerhebel_frame)
	(M.L.wischer_drehschalter_frame)
	(M.L.oeldruck_frame)
	(M.L.cockpitlights_frame)
	(M.L.schluessel_frame)
	(M.L.lichtdreh_frame)
	(M.L.odometer_frame)
	(M.L.fahrertuer_frame) 
	(M.L.rollo_frame)
	(M.L.rolloF_frame)
	(M.L.microphone_frame)
'	(M.L.Thermometer_frame)
	(M.L.Kamera_frame)
	(M.L.kneel_frame)
	(M.L.blinkgeber_frame)
	(M.L.funk_frame)
	(M.L.VDV_frame)
{end}

{macro:cockpit_frame_AI}
'   Anpassung diverser Schalterstellungen für KI-Übernahme
    1 (S.L.cp_schluessel_trans_mode) (S.L.cp_schluessel_trans)

    (L.L.AI_Engine) 1 = 
    {if}
        2 (S.L.cp_schluessel_rot_mode) (S.L.cp_schluessel_rot)
    {endif}
    
    (L.L.AI_Engine) -1 = 
    {if}
        1 (S.L.cp_schluessel_rot_mode) (S.L.cp_schluessel_rot)
    {endif}
{end}

{macro:tacho_frame}
	(L.L.Velocity) (F.L.cockpit_tacholinie) (S.L.cockpit_tachowinkel)
{end}

{macro:uhr_frame}
	(L.S.Time) 3600 / trunc " 2" s0
	(L.S.Time) 60 / l0 60 * - s1 
 
	l0 10 <
	{if}
	"0" l0 $IntToStr $+
	{else}
	l0 $IntToStr
	{endif}
 
	l1 10 <
	{if}
	":0" $+ l1 $IntToStr $+
	{else}
	":" $+ l1 $IntToStr $+
	{endif}
 
	(S.$.Uhrzeit)
{end} 


{macro:hupe_frame}
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	{if}
		(L.L.cockpit_hupe) 1 =
		{if}
			(L.L.cockpit_hupe_volume) 1 <
			{if}
				(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * + (S.L.cockpit_hupe_volume)
			{else}
				1 (S.L.cockpit_hupe_volume)
			{endif}
		{else}
			(L.L.cockpit_hupe_volume) 0 >
			{if}
				(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * - (S.L.cockpit_hupe_volume)
			{else}
				0 (S.L.cockpit_hupe_volume)
			{endif}
		{endif}
	{else}
		(L.L.cockpit_hupe_volume) 0 >
		{if}
			(L.L.cockpit_hupe_volume) (L.S.Timegap) 10 * - (S.L.cockpit_hupe_volume)
		{else}
			0 (S.L.cockpit_hupe_volume)
		{endif}
	{endif}	
	
{end}

{macro:blinkerhebel_frame}
	(L.L.lights_sw_blinker) 1 =
	{if}	
		-1 (S.L.cockpit_blinkerhebel)
	{else}
		(L.L.lights_sw_blinker) 2 =
		{if}
			1 (S.L.cockpit_blinkerhebel)
		{else}
			0 (S.L.cockpit_blinkerhebel)
		{endif}
	{endif}

'	Hebel-Animation für Fernlicht
	(L.L.lights_sw_fern)
	{if}	
		(L.L.cockpit_fernlichthebel) -1 = !
		{if}
			1 (S.L.cockpit_fernlichthebel)
		{endif}

		(L.L.cp_lichtdreh_rot_mode) 1 >=
		{if}
			-1 (S.L.cockpit_fernlichthebel)
		{endif}
	{else}
		0 (S.L.cockpit_fernlichthebel)
	{endif}


{end}

{macro:wischerhebel_frame}

	(L.L.cockpit_wischerhebel_lastmode) (L.L.cockpit_wischerhebel_mode) = !
	{if}
		(T.L.ev_wischerhebel)
	{endif}
	(L.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischerhebel_lastmode)
{end}

{macro:wischer_drehschalter_frame}

	(L.L.cockpit_wischer_drehschalter_lastmode) (L.L.cockpit_wischer_drehschalter_mode) = !
	{if}
		(T.L.ev_wischerhebel)
	{endif}
	(L.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischer_drehschalter_lastmode)
{end}



{macro:cockpitlights_frame}

'	Störungsmelder
	(L.L.engine_n) 100 <
	(L.L.bremse_p_tank01) 650000 < ||
	(L.L.bremse_p_tank02) 650000 < ||
	(L.L.bremse_p_tank03) 650000 < ||
	(L.L.elec_busbar_main) *
	(S.L.cockpit_light_masterfailure)

'	Batterie
'	Türkontrolle
'   neu mit Hintertür
	(L.L.door_2) 0.02 > 
	(L.L.door_3) 0.02 > ||
	(L.L.door_4) 0.02 > ||
	(L.L.door_5) 0.02 > ||
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
	(S.L.cockpit_light_tuerkontrolle)

'	Kontrolle Feststellbremse
	(L.L.bremse_p_Brzyl_FBA) 650000 <
	(L.L.elec_busbar_main) *
	(S.L.cockpit_light_feststellbremse)

'	Geschwindigkeitswarnung	
'	Kinderwagenwunsch
	(L.L.door_kinderwagenwunsch) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_kinderwagenwunsch)

'	Kippschalter-Beleuchtung
	(L.L.cp_fahrerlicht_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_fahrerlicht)

	(L.L.cp_licht_untenrechts_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_licht_untenrechts)

	(L.L.cp_licht_unterdeck_sw) 0 = ! (L.L.elec_busbar_main) *
	(S.L.cockpit_light_licht_unterdeck)

	(L.L.cp_licht_oberdeck_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_licht_oberdeck)

'	Dummy-Schalter:

	(L.L.cp_dummy_sw01) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func01)

	(L.L.cp_dummy_sw02) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func02)

	(L.L.cp_dummy_sw03) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func03)

	(L.L.cp_dummy_sw04) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func04)

	(L.L.cp_dummy_sw05) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func05)

	(L.L.cp_dummy_sw06) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func06)

	(L.L.cp_dummy_sw07) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func07)

	(L.L.cp_dummy_sw08) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func08)

	(L.L.cp_dummy_sw09) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func09)

	(L.L.cp_dummy_sw10) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_func10)
		
' andere Lichter
	(L.L.antrieb_getr_gangvorwahl) 1 = (L.L.elec_busbar_main) 0.1 > && (S.L.cockpit_light_gangN)
	
{end}

{macro:oeldruck_frame}
	(L.L.engine_n) (F.L.cockpit_oeldruck) (L.L.elec_busbar_main) * s0

	(L.L.cockpit_oeldruck) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_oeldruck)
{end}
	

{macro:kippschaltersound}
	l1
	{if}
		(T.L.ev_kippschalter_ein)
	{else}
		(T.L.ev_kippschalter_aus)
	{endif}	
{end}

{macro:wippschaltersound}
	l1
	{if}
		(T.L.ev_haltebremse_sw_an)
	{else}
		(T.L.ev_haltebremse_sw_aus)
	{endif}	
{end}

{macro:klappfenstersound}
	l1
	{if}
		(T.L.ev_klappfenster_opn)
	{else}
		(T.L.ev_klappfenster_cls)
	{endif}	
{end}




{macro:schluessel_frame}
	(L.L.cp_schluessel_trans_lastmode) (L.L.cp_schluessel_trans_mode) = !
	{if}
		(T.L.ev_schluessel_steck)
	{endif}
	(L.L.cp_schluessel_trans_mode) (S.L.cp_schluessel_trans_lastmode)

	(L.L.cp_schluessel_rot_lastmode) (L.L.cp_schluessel_rot_mode) = !
	{if}
		(T.L.ev_schluessel_dreh)
	{endif}
	(L.L.cp_schluessel_rot_mode) (S.L.cp_schluessel_rot_lastmode)
{end}

{macro:lichtdreh_frame}
	(L.L.cp_lichtdreh_trans_lastmode) (L.L.cp_lichtdreh_trans_mode) = !
	{if}
		(T.L.ev_kippschalter_ein)
	{endif}
	(L.L.cp_lichtdreh_trans_mode) (S.L.cp_lichtdreh_trans_lastmode)

	(L.L.cp_lichtdreh_rot_lastmode) (L.L.cp_lichtdreh_rot_mode) = !
	{if}
		(T.L.ev_kippschalter_aus)
	{endif}
	(L.L.cp_lichtdreh_rot_mode) (S.L.cp_lichtdreh_rot_lastmode)
{end}

{macro:wischer_drehschalter_frame}

	(L.L.cockpit_wischer_drehschalter_lastmode) (L.L.cockpit_wischer_drehschalter_mode) = !
	{if}
		(T.L.ev_wischerhebel)
	{endif}
	(L.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischer_drehschalter_lastmode)
{end}

{macro:traegheit}

'Simuliert träges Verhalten (exponentiell)

'Ladekonventionen:
'	Sollwert		l0
'	Istwert			l1
'	Konstante Anlauf	l2 (Einheiten/s)
'	Konstante Ablauf	l3 (Einheiten/s)

'Anlauf oder Auslauf?
	l0 l1 > 
	{if}
		l2 (L.S.Timegap) * 1 min -1 max s4
	{else}
		l3 (L.S.Timegap) * 1 min -1 max s4
	{endif}


'Sollwert:
	l0
'Istwert:
	l1
'Beschleunigung:
	- l4 *
'Addition zum Istwert:
	l1 + s1
{end}


{macro:odometer_frame}

	(L.L.kmcounter_km) (L.L.kmcounter_m) 1000 / + (S.L.km_counter_km)
	(L.L.km_counter_km) 10 * trunc 10 / (S.L.km_counter_km)
	(L.L.kmcounter_m) "04" $IntToStrEnh 3 $SetLengthR (S.$.km_counter_m)
	(L.$.km_counter_m) 1 $SetLengthL $StrToFloat trunc (S.L.km_counter_m)

	(L.L.elec_busbar_main) 0.1 >
	{if}
		(L.L.km_counter_km) trunc " 7" $IntToStrEnh 6 $SetLengthR
		"." $+
		(L.$.km_counter_m) 1 $SetLengthL $+
		(S.$.odometr_full)
	{else}
		" " $ (S.$.odometr_full)
	{endif}
{end}


{macro:fahrertuer_frame}

	(L.L.cp_fahrertuer_dragged) !
	{if}
		(L.L.cp_fahrertuer_pos) (L.S.Timegap) (L.L.cp_fahrertuer_speed) * + (S.L.cp_fahrertuer_pos)

		(L.L.cp_fahrertuer_pos) 1 >
		{if}
			1 (S.L.cp_fahrertuer_pos)
			(L.L.cp_fahrertuer_speed) /-/ 0.7 * (S.L.cp_fahrertuer_speed)
		{endif}
		(L.L.cp_fahrertuer_pos) 0 <
		{if}
			0 (S.L.cp_fahrertuer_speed) (S.L.cp_fahrertuer_pos)
		{endif}

		(L.L.cp_fahrertuer_pos) 0 >
		{if}
			(L.L.cp_fahrertuer_speed) (L.S.Timegap) (L.L.A_Trans_Y) (C.L.cp_fahrertuer_anschlagseite) * (L.L.A_Trans_X) /-/ + 0.3 * (L.L.cp_fahrertuer_globalangle) * * + (S.L.cp_fahrertuer_speed)
		{endif}
	
		(L.L.cp_fahrertuer_speed) s0 (S.L.cp_fahrertuer_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.cp_fahrertuer_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.cp_fahrertuer_speed)
		{endif}


		(L.L.cp_fahrertuer_speed) 0 > (L.L.cp_fahrertuer_lastspeed) 0 < &&
		(L.L.cp_fahrertuer_speed) 0 < (L.L.cp_fahrertuer_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_fahrertuer_speed)
		{endif}	 
	
	{endif}

	(L.L.cp_fahrertuer_pos) 0 > (L.L.cp_fahrertuer_open) ! &&
	{if}
		(T.L.ev_fahrertuer_auf)
		1 (S.L.cp_fahrertuer_open)
	{endif}

	(L.L.cp_fahrertuer_pos) 0 = (L.L.cp_fahrertuer_open) &&
	{if}
		(T.L.ev_fahrertuer_zu)
		0 (S.L.cp_fahrertuer_open)
	{endif}

	(L.L.cp_fahrertuer_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_fahrertuer_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)
	

{end}

{macro:rollo_frame}
	(L.L.cp_rollo_pos) (L.L.cp_rollo_rastpos) max (S.L.cp_rollo_rastpos)

	(L.L.cp_rollo_dragged) !
	{if}
		(L.L.cp_rollo_retract)
		{if}
			(L.L.cp_rollo_speed) (L.S.Timegap) (L.L.cp_rollo_pos) 14 * * - (S.L.cp_rollo_speed)
			(L.L.cp_rollo_pos) (L.S.Timegap) (L.L.cp_rollo_speed) * + (S.L.cp_rollo_pos) (S.L.cp_rollo_rastpos)
					
		{else}
			(L.L.cp_rollo_pos) (L.L.cp_rollo_rastpos) < 
			{if}
				(L.L.cp_rollo_speed) (L.S.Timegap) 14 * + (S.L.cp_rollo_speed)
				(L.L.cp_rollo_pos) (L.S.Timegap) (L.L.cp_rollo_speed) * + (L.L.cp_rollo_rastpos) min (S.L.cp_rollo_pos)
			{else}
				0 (S.L.cp_rollo_speed)
			{endif}
		{endif}

		(L.L.cp_rollo_pos) 1 >
		{if}
			1 (S.L.cp_rollo_pos) (S.L.cp_rollo_rastpos)
		{else}
			(L.L.cp_rollo_pos) 0 <
			{if}
			0 (S.L.cp_rollo_pos) (S.L.cp_rollo_retract) (S.L.cp_rollo_rastpos)
			{endif}
		{endif}

	{endif}
{end}

'Fahrerrollo

{macro:rolloF_frame}
	(L.L.cp_rolloF_pos) (L.L.cp_rolloF_rastpos) max (S.L.cp_rolloF_rastpos)

	(L.L.cp_rolloF_dragged) !
	{if}
		(L.L.cp_rolloF_retract)
		{if}
			(L.L.cp_rolloF_speed) (L.S.Timegap) (L.L.cp_rolloF_pos) 14 * * - (S.L.cp_rolloF_speed)
			(L.L.cp_rolloF_pos) (L.S.Timegap) (L.L.cp_rolloF_speed) * + (S.L.cp_rolloF_pos) (S.L.cp_rolloF_rastpos)
					
		{else}
			(L.L.cp_rolloF_pos) (L.L.cp_rolloF_rastpos) < 
			{if}
				(L.L.cp_rolloF_speed) (L.S.Timegap) 14 * + (S.L.cp_rolloF_speed)
				(L.L.cp_rolloF_pos) (L.S.Timegap) (L.L.cp_rolloF_speed) * + (L.L.cp_rolloF_rastpos) min (S.L.cp_rolloF_pos)
			{else}
				0 (S.L.cp_rolloF_speed)
			{endif}
		{endif}

		(L.L.cp_rolloF_pos) 1 >
		{if}
			1 (S.L.cp_rolloF_pos) (S.L.cp_rolloF_rastpos)
		{else}
			(L.L.cp_rolloF_pos) 0 <
			{if}
			0 (S.L.cp_rolloF_pos) (S.L.cp_rolloF_retract) (S.L.cp_rolloF_rastpos)
			{endif}
		{endif}

	{endif}
{end}



{macro:microphone_frame}

	(L.L.Clutch) 0.2 > (L.L.cp_microphone_sw) ||
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) > && s0
	(L.L.Snd_Microphone) s1


	l0 l1 ! &&
	{if}
		(T.L.micro_lautsprecherknack_start)
	{endif}

	l0 ! l1 &&
	{if}
		(T.L.micro_lautsprecherknack_end)
	{endif}


	l0 (S.L.Snd_Microphone)
{end}


{macro:Thermometer_frame}

	(L.L.Cabinair_Temp) s0 trunc " 3" $IntToStrEnh "." $+ 
	l0 abs l0 abs trunc - 10 * trunc " 1" $IntToStrEnh $+ "C" $+
	(S.$.cockpit_temperatur)
{end}

' Kamera-Monitor

{macro:Kamera_frame}
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	{if}
		(L.L.kamera_mode_weiter)
		(L.L.Velocity) 5 < &&
		(L.L.door_0) 0 = &&
		(L.L.door_1) 0 = &&
		{if}
			(L.L.kamera_mode) 1 + (S.L.kamera_mode) 7 = {if} 1 (S.L.kamera_mode) {endif}
		{endif}
		0 (S.L.kamera_mode_weiter)
	
		(L.L.antrieb_getr_aktugang) 1 = (L.L.antrieb_getr_gangvorwahl) 0 = && (L.L.lights_sw_blinker) 2 = ||
		{if}
			1 (S.L.kamera_blinker_active)
			0 (S.L.kamera_mode_timer)
		{else}
		(L.L.kamera_blinker_active)
		(L.L.kamera_mode) 6 = &&
		{if}
			(L.L.kamera_mode_timer) (L.S.Timegap) + (S.L.kamera_mode_timer) 4 >
			{if}
				0 (S.L.kamera_blinker_active)
			{endif}
		{else}
			0 (S.L.kamera_blinker_active)
		{endif}
		{endif}
	
		(L.L.door_0) 0.02 >
		(L.L.door_1) 0.02 > ||
		(L.L.door_2) 0.02 > ||
		(L.L.door_4) 0.02 > ||
		{if}
			(L.L.kamera_mode_auto) 2 = !
			{if}
				2 (S.L.kamera_mode) (S.L.kamera_mode_auto)
			{endif}
		{else}
		(L.L.kamera_blinker_active)
		{if}
			(L.L.kamera_mode_auto) 6 = !
			{if}
				6 (S.L.kamera_mode) (S.L.kamera_mode_auto)
			{endif}
		{else}
		(L.L.kamera_mode_auto) 4 = !
		(L.L.Velocity) 5 > ||
		{if}
			4 (S.L.kamera_mode) (S.L.kamera_mode_auto)
		{endif}
		{endif}
		{endif}
	{else}	
		0 (S.L.kamera_mode) (S.L.kamera_mode_auto) (S.L.kamera_mode_weiter)
	{endif}
    
'Diverse Werte für die Beeinflussung der statischen Kamerabilder zwischenspeichern:
    (L.L.Envir_Brightness) 0.7 > s1
    (L.L.humans_count) 0 > s2
    (L.L.door_0) 0 > (L.L.door_1) 0 > || s3
    (L.L.lights_beleuchtung_oberdeck) s4
    (L.L.lights_beleuchtung_unterdeck) s5
    (L.L.lights_beleuchtung_untenrechts) s6
        
'Texturen zuweisen:
    (L.L.kamera_mode) s0 6 = (S.L.kamera_refl3_visible)
    l0 1 =
    {if}
        "refl8_" l1 $IntToStr $+ "_" $+ l2 $IntToStr $+ "_" $+ l5 $IntToStr $+ ".png" $+ (S.$.kamera_tex)
    {else}
    l0 2 =
    {if}
        "refl4_" l1 $IntToStr $+ "_" $+ l3 $IntToStr $+ "_" $+ l6 $IntToStr $+ ".png" $+ (S.$.kamera_tex)
    {else}
    l0 3 =
    {if}
        "refl5_" l1 $IntToStr $+ "_" $+ l2 $IntToStr $+ "_" $+ l5 $IntToStr $+ ".png" $+ (S.$.kamera_tex)
    {else}
    l0 4 =
    {if}
        "refl6_" l1 $IntToStr $+ "_" $+ l2 $IntToStr $+ "_" $+ l4 $IntToStr $+ ".png" $+ (S.$.kamera_tex)
    {else}
    l0 5 =
    {if}
        "refl7_" l1 $IntToStr $+ "_" $+ l2 $IntToStr $+ "_" $+ l4 $IntToStr $+ ".png" $+ (S.$.kamera_tex)
    {else}
'       wenn keiner der o.g. Modi aktiv, "aus"-Textur anzeigen
        "refl0.png" (S.$.kamera_tex)
    {endif}
    {endif}
    {endif}
    {endif}
    {endif}
    
    
{end}

' Steuerung Kneeling

{macro:kneel_frame}    
    (L.L.kneel_uplock) (L.L.cp_kneel_sw) 1 = || (L.L.bremse_halte) && (L.L.cp_kneel_sw) -1 = ! && (S.L.kneel_uplock)

    (L.L.bremse_halte)
    (L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
    (L.L.cockpit_light_masterfailure) 0 = && s0
    (L.L.kneel_uplock) ! &&
    (L.L.door_freigabe) (L.L.doorTarget_0) (L.L.doorTarget_1) (L.L.doorTarget_23) (L.L.doorTarget_45) || || || || &&
    {if}
        -0.03 (S.L.kneel_setpoint)
    {else}
        0 (S.L.kneel_setpoint)
    {endif}
    
    (L.L.cp_kneel_sw) -1 =
    (L.L.kneel_istpoint) -0.05 < ||
    (L.L.kneel_setpoint) -0.03 = &&
    {if}
        -0.07 (S.L.kneel_setpoint)
    {endif}
  
    (L.L.Axle_Suspension_0_L) (C.L.bremse_level_setpoint) - (S.L.kneel_istpoint)
    
    (L.L.kneel_setpoint) 0     = (L.L.kneel_istpoint) -0.005 < &&
    (L.L.kneel_setpoint) -0.03 = (L.L.kneel_istpoint) -0.035 < && || l0 &&
    (S.L.kneel_upsound)

    (L.L.kneel_setpoint) -0.03 = (L.L.kneel_istpoint) -0.02 > &&
    (L.L.kneel_setpoint) -0.07 = (L.L.kneel_istpoint) -0.06 > && || l0 &&
    (S.L.kneel_downsound)
    
    (L.L.kneel_setpoint) -0.07 =
    (L.L.kneel_upsound) (L.L.kneel_downsound) || ! &&
    {if}
        -0.07 (S.L.kneel_setpoint)
    {endif}
    
{end}

' Funk

{macro:funk_frame}  
(L.L.elec_busbar_main)
{if}
    (L.L.funk_timer) (L.S.Timegap) + (S.L.funk_timer)

    (L.L.cp_microphone_sw) 
    (L.L.funk_state) 0 = &&
    {if}
        (T.L.ev_ALMEX_piep_abfahren)
        1 (S.L.funk_state)
        0 (S.L.funk_timer)
    {endif}
    
    (L.L.funk_timer) 2 >
    (L.L.funk_state) 1 = &&
    (L.L.cp_microphone_sw) ! &&
    {if}
        (T.L.ev_ALMEX_piep_abfahren)
        2 (S.L.funk_state)
        0 (S.L.funk_timer)
        15 random 15 + (S.L.funk_responsetime)
    {endif}
    
    (L.L.funk_state) 2 =
    (L.L.funk_timer) (L.L.funk_responsetime) > &&
    {if}
        (T.L.ev_ALMEX_piep_abfahren)
        (L.L.funk_count) 1 + (S.L.funk_count) 11 random <
        {if}
            3 (S.L.funk_state)
        {else}
            5 (S.L.funk_state)
        {endif}
        0 (S.L.funk_timer)
        3 (S.L.funk_responsetime)
    {endif}
    
    (L.L.funk_state) 3 =
    (L.L.funk_timer) (L.L.funk_responsetime) > &&
    {if}
        3 random s0
        l0 0 = {if} "Funk\Kommen.wav" {endif}
        l0 1 = {if} "Funk\Leitstelle hoert.wav" {endif}
        l0 2 = {if} "Funk\Sprechen Sie.wav" {endif}
        (T.F.ev_Funkspruch)
        4 (S.L.funk_state)
        0 (S.L.funk_timer)
        10 random 15 + (S.L.funk_responsetime)
    {endif}
    
    (L.L.funk_state) 4 =
    (L.L.funk_timer) (L.L.funk_responsetime) > &&
    {if}
        10 random s0
        l0 0 = {if} 3 (S.L.funk_responsetime) "Funk\Bitte nur Dringende.wav" {endif}
        l0 1 = {if} 3 (S.L.funk_responsetime) "Funk\Da kann ich Ihnen leider nicht helfen.wav" {endif}
        l0 2 = {if} 4 (S.L.funk_responsetime) "Funk\Dann einmal bitte bei der naechsten Gelegenheit rechts ranfahren.wav" {endif}
        l0 3 = {if} 3 (S.L.funk_responsetime) "Funk\Das glauben Sie doch wohl selber nicht.wav" {endif}
        l0 4 = {if} 4 (S.L.funk_responsetime) "Funk\Das kann ich mir beim besten Willen nicht vorstellen.wav" {endif}
        l0 5 = {if} 3 (S.L.funk_responsetime) "Funk\Einen ganz kleinen Augenblick bitte.wav" {endif}
        l0 6 = {if} 3 (S.L.funk_responsetime) "Funk\Hallo koennen Sie mich hoeren.wav" {endif}
        l0 7 = {if} 3 (S.L.funk_responsetime) "Funk\Ich kann Sie nicht verstehen 3.wav" {endif}
        l0 8 = {if} 3 (S.L.funk_responsetime) "Funk\Sie kennen die Dienstanweisung 2.wav" {endif}
        l0 9 = {if} 3 (S.L.funk_responsetime) "Funk\Steht dazu vielleicht etwas im Handbuch 2.wav" {endif}
        (T.F.ev_Funkspruch)
        6 (S.L.funk_state)
        0 (S.L.funk_timer)
    {endif}
    
    (L.L.funk_state) 5 =
    (L.L.funk_timer) (L.L.funk_responsetime) > &&
    {if}
        "Funk\Bitte nur Dringende.wav" (T.F.ev_Funkspruch)
        3 (S.L.funk_responsetime)
        6 (S.L.funk_state) 
        0 (S.L.funk_timer)
    {endif}
    
    (L.L.funk_state) 6 =
    (L.L.funk_timer) (L.L.funk_responsetime) > &&
    {if}
        (T.L.ev_ALMEX_piep_abfahren)
        0 (S.L.funk_state) (S.L.funk_timer) (S.L.funk_responsetime)
    {endif}
    
{else}
    0 (S.L.funk_timer) (S.L.funk_state) (S.L.funk_responsetime)
{endif}

(L.L.funk_count) (L.S.Timegap) 1000 / - 0 max (S.L.funk_count)
{end}

' blinkende Leuchten 0,667 Hz Verhältnis 2:1

{macro:blinkgeber_frame}

	(L.L.cp_blinkgeber) 0.5 >
	{if}
	-1 (S.L.cp_blinkgeber)
	{endif}
	(L.L.cp_blinkgeber) (L.S.Timegap) + (S.L.cp_blinkgeber)
{end}

' VDV-Display neu
{macro:VDV_frame}
	
' Timer laufen lassen
	(L.L.vdv_mode_delay) (L.S.Timegap) + (S.L.vdv_mode_delay) 0 >=
	{if}
		(L.L.vdv_mode_timer) (L.S.Timegap) + (S.L.vdv_mode_timer)
	{endif}
       
' Ein- / Ausschalten des Displays und Startsequenz
	(L.L.elec_busbar_main) 0 = (L.L.vdv_mode) -1 = ! &&
	{if}
		-1 (S.L.vdv_mode) (S.L.vdv_mode_soll)
        1 (M.V.STNewTex)
	{endif}
	
	(L.L.elec_busbar_main) 0.1 > (L.L.vdv_mode) -1 = &&
	{if}
		0 (S.L.vdv_mode)
		99 (S.L.vdv_mode_soll)
		1 (S.L.vdv_startsequenz)
		-2 (S.L.vdv_mode_timer)
	{endif}
	
	(L.L.vdv_startsequenz)
	(L.L.vdv_mode) 3 >= &&
	{if}
        (L.L.vdv_mode_soll) 99 =
		(L.L.vdv_mode_timer) 6 > &&
		{if}
            3 (S.L.vdv_mode_soll)
			-1 (S.L.vdv_mode_timer)
		{else}
        (L.L.vdv_mode_soll) 99 <
		(L.L.vdv_mode_timer) 3 > &&
		{if}
			(L.L.vdv_mode_soll) 1 + (S.L.vdv_mode_soll) 6 =
			{if}
				1 (S.L.vdv_mode_soll)
				0 (S.L.vdv_startsequenz)
			{endif}
			-0.3 (S.L.vdv_mode_timer)
		{endif}
		{endif}
	{endif}
	
' Hintergrundtextur:
    (L.L.vdv_mode) -1 =
    {if}
        "vdv_BG_off.bmp" (S.$.vdv_tex_BG)
    {else}
        (L.L.cp_lichtdreh_rot_mode) 1 >=
        {if}
            "vdv_BG_N.bmp" (S.$.vdv_tex_BG)
            "vdv_color_N.bmp" (S.$.vdv_tex_color)
        {else}
            "vdv_BG.bmp" (S.$.vdv_tex_BG)
            "vdv_color.bmp" (S.$.vdv_tex_color)
        {endif}
    {endif}
            
	
' Modi durchschalten:
	(L.L.vdv_mode_weiter)
	(L.L.vdv_mode) -1 = ! &&
	(L.L.vdv_startsequenz) ! &&
	{if}
		(L.L.vdv_mode_soll) 1 + (S.L.vdv_mode_soll) 
		s0 2 = {if} 3 (S.L.vdv_mode_soll) {endif}
		l0 9 = {if} 1 (S.L.vdv_mode_soll) {endif}
		-0.3 (S.L.vdv_mode_timer)
		-0.2 (S.L.vdv_mode_delay)
	{endif}
	0 (S.L.vdv_mode_weiter)
	
' Nach 5 Sek. in Fahrtmodus zurückschalten
	(L.L.vdv_mode) 3 >=
	(L.L.vdv_startsequenz) ! &&
	{if}
		(L.L.vdv_mode_timer) 5 >
		{if}
			1 (S.L.vdv_mode_soll)
			-0.3 (S.L.vdv_mode_timer)
		{endif}
	{endif}
    
' Wechsel in Standmodus bei aktiver Haltestellen- oder Feststellbremse
	(L.L.bremse_halte) (L.L.cockpit_light_feststellbremse) || (L.L.Velocity) 1 < &&
	(L.L.vdv_mode_soll) 1 = &&
	{if}
		2 (S.L.vdv_mode_soll)
		(L.L.vdv_mode_timer) -0.3 = !
		{if}
			-1 (S.L.vdv_mode_timer)
			-0.1 (S.L.vdv_mode_delay)
		{endif}
	{endif}
		
	(L.L.bremse_halte) ! (L.L.cockpit_light_feststellbremse) ! &&
	(L.L.vdv_mode_soll) 2 = &&
    {if}
		1 (S.L.vdv_mode_soll)
		-1 (S.L.vdv_mode_timer)
		-0.5 (S.L.vdv_mode_delay)
	{endif}
	
' Moduswechsel mit Verzögerung:
	(L.L.vdv_mode) (L.L.vdv_mode_soll) = !
	(L.L.vdv_mode) -1 = ! &&
	(L.L.vdv_mode_delay) 0 >= &&
	{if}
        (L.L.vdv_mode) 0 >
		{if}
            0 (S.L.vdv_mode)
            1 (M.V.STNewTex)
            1 (S.L.vdv_refresh)
		{endif}
		(L.L.vdv_mode_timer) 0 >=
		{if}
			(L.L.vdv_mode_soll) (S.L.vdv_mode)
			0 (S.L.vdv_mode_timer)
            1 (M.V.STNewTex)
            1 (S.L.vdv_refresh)
		{endif}
	{endif}

(L.L.door_0) {if} (L.L.vdv_doortimer_0)  (L.S.Timegap) + 0 max (S.L.vdv_doortimer_0)  {else} (L.L.vdv_doortimer_0)  (L.S.Timegap) - 0 min (S.L.vdv_doortimer_0)  {endif}
(L.L.door_1) {if} (L.L.vdv_doortimer_1)  (L.S.Timegap) + 0 max (S.L.vdv_doortimer_1)  {else} (L.L.vdv_doortimer_1)  (L.S.Timegap) - 0 min (S.L.vdv_doortimer_1)  {endif}
(L.L.door_2) {if} (L.L.vdv_doortimer_23) (L.S.Timegap) + 0 max (S.L.vdv_doortimer_23) {else} (L.L.vdv_doortimer_23) (L.S.Timegap) - 0 min (S.L.vdv_doortimer_23) {endif}
(L.L.door_4) {if} (L.L.vdv_doortimer_45) (L.S.Timegap) + 0 max (S.L.vdv_doortimer_45) {else} (L.L.vdv_doortimer_45) (L.S.Timegap) - 0 min (S.L.vdv_doortimer_45) {endif}

(L.L.door_freigabe)          {if} (L.L.vdv_freigabe_timer)    (L.S.Timegap) + 0 max (S.L.vdv_freigabe_timer)    {else} (L.L.vdv_freigabe_timer)    (L.S.Timegap) - 0 min (S.L.vdv_freigabe_timer)    {endif}
(L.L.haltewunschlampe)       {if} (L.L.vdv_haltewunsch_timer) (L.S.Timegap) + 0 max (S.L.vdv_haltewunsch_timer) {else} (L.L.vdv_haltewunsch_timer) (L.S.Timegap) - 0 min (S.L.vdv_haltewunsch_timer) {endif}
(L.L.door_kinderwagenwunsch) {if} (L.L.vdv_kinderwagen_timer) (L.S.Timegap) + 0 max (S.L.vdv_kinderwagen_timer) {else} (L.L.vdv_kinderwagen_timer) (L.S.Timegap) - 0 min (S.L.vdv_kinderwagen_timer) {endif}

(L.L.vdv_doortimer_0)   1 > {if} 1 (S.L.vdv_doorstate_0)  {endif}
(L.L.vdv_doortimer_0)  -1 < {if} 0 (S.L.vdv_doorstate_0)  {endif}
(L.L.vdv_doortimer_1)   1 > {if} 1 (S.L.vdv_doorstate_1)  {endif}
(L.L.vdv_doortimer_1)  -1 < {if} 0 (S.L.vdv_doorstate_1)  {endif}
(L.L.vdv_doortimer_23)  1 > {if} 1 (S.L.vdv_doorstate_23) {endif}
(L.L.vdv_doortimer_23) -1 < {if} 0 (S.L.vdv_doorstate_23) {endif}
(L.L.vdv_doortimer_45)  1 > {if} 1 (S.L.vdv_doorstate_45) {endif}
(L.L.vdv_doortimer_45) -1 < {if} 0 (S.L.vdv_doorstate_45) {endif}

(L.L.vdv_freigabe_timer)     1 > {if} 1 (S.L.vdv_freigabe) {endif}
(L.L.vdv_freigabe_timer)    -1 < {if} 0 (S.L.vdv_freigabe) {endif}
(L.L.vdv_haltewunsch_timer)  0.2 > {if} 1 (S.L.vdv_haltewunsch) {endif}
(L.L.vdv_haltewunsch_timer) -1.2 < {if} 0 (S.L.vdv_haltewunsch) {endif}
(L.L.vdv_kinderwagen_timer)  1 > {if} 1 (S.L.vdv_kinderwagen) {endif}
(L.L.vdv_kinderwagen_timer) -1 < {if} 0 (S.L.vdv_kinderwagen) {endif}
    
'Kriterien für Aktualisierung der Scripttextur - je nach angezeigtem Modus unterschiedlich
(L.L.vdv_mode) 1 =
(L.L.vdv_mode) 2 = ||
{if}
    (L.L.bremse_halte) $IntToStr
    (L.L.vdv_freigabe) $IntToStr $+
    (L.L.vdv_haltewunsch) $IntToStr $+
    (L.L.vdv_kinderwagen) $IntToStr $+
    (L.L.cockpit_light_feststellbremse) $IntToStr $+
    (L.L.engine_tank_content) 50 < $IntToStr $+
    (L.L.antrieb_getr_aktugang) $IntToStr $+
    (L.L.antrieb_getr_gangvorwahl) $IntToStr $+
    (L.L.engine_n) 200 < $IntToStr $+
    (L.L.antrieb_retarder) 0.05 > $IntToStr $+
    (L.L.tank_percent) trunc $IntToStr $+
    (L.L.cp_lichtdreh_rot_mode) 1 >= $IntToStr $+
    (L.L.kneel_upsound) (L.L.kneel_downsound) || $IntToStr $+
    (L.L.cp_tuerfluegelsperre_sw) $IntToStr $+
    (L.L.door_rampe_1_active) $IntToStr $+
    (L.L.door_rampe_2_active) $IntToStr $+
    (L.L.vdv_doorstate_0) $IntToStr $+
    (L.L.vdv_doorstate_1) $IntToStr $+
    (L.L.vdv_doorstate_23) $IntToStr $+
    (L.L.vdv_doorstate_45) $IntToStr $+
    (L.$.ALMEX_CockpitLine1) $+
    (L.$.ALMEX_CockpitLine2) $+
    (S.$.vdv_content_new)
{endif}
(L.$.vdv_content_new) (L.$.vdv_content) $= !
{if}
    1 (S.L.vdv_refresh)
{endif}
(L.$.vdv_content_new) (S.$.vdv_content)

(L.L.vdv_blink) s0
(L.S.GetTime) 1.6 % 1.1 < (S.L.vdv_blink) l0 = !
{if}
    1 (S.L.vdv_refresh)
{endif}


'Initstate für Haltestellenmodus
(L.L.vdv_mode) 2 =
{if}
    (L.L.vdv_initstate) 0 =
    (L.L.vdv_mode_timer) 1 > &&
    {if}
        1 (S.L.vdv_initstate)
        1 (S.L.vdv_refresh)
    {endif}
{else}
    0 (S.L.vdv_initstate)
{endif}
    
'Aktualisieren der Skripttextur
(L.L.vdv_refresh)
{if}
    0 (S.L.vdv_refresh)
    
'   Textur locken und Farbe setzen
    1 (M.V.STLock)
    
    1
    255
    0
    0
    0
    (M.V.STSetColor)
    
    
    
    
'   "Zeile 1" (Symbole ganz oben)
    (L.L.vdv_mode) 1 =
    {if}
        "X10_vdv_symbole_20" (M.V.GetFontIndex) s1 
        
        (L.L.antrieb_retarder) 0.05 > {if} "R" {else} "|" 26 $* {endif}
        (S.$.vdv_symbole)
                
        1
        5
        5
        l1
        0
        0
        (L.$.vdv_symbole)
        (M.V.STTextOut)
    {endif}
    
'   "Zeile 3 u. 4" (Symbole mittig + ALMEX-Text)
    (L.L.vdv_mode) 1 =
    (L.L.vdv_mode) 2 = ||
    {if}
'       Ganganzeige
        "X10_vdv_symbole_27" (M.V.GetFontIndex) s1
        (L.L.engine_n) 200 <
        {if}
            "|" 26 $*
        {else}
            (L.L.antrieb_getr_aktugang) 1 = 
            (L.L.antrieb_getr_gangvorwahl) 0 = && 
            {if}
                "R"
            {else}
            (L.L.antrieb_getr_aktugang) 0 =
            (L.L.antrieb_getr_gangvorwahl) 1 = &&
            {if}
                "N"
            {else}
            (L.L.antrieb_getr_aktugang) 1 = 
            (L.L.antrieb_getr_aktugang) 0 = || 
            (L.L.antrieb_getr_gangvorwahl) 1 > &&
            {if}
                "1"
            {else}
                (L.L.antrieb_getr_aktugang) $IntToStr
            {endif}
            {endif}
            {endif}
        {endif}
        
        1
        5
        69
        l1
        0
        0
        
        (M.V.STTextOut)
        
'       Symbole neben der Ganganzeige
        "X10_vdv_symbole_20" (M.V.GetFontIndex) s1
    
        (L.L.vdv_haltewunsch)         {if} "H" {else} "|" 30 $* {endif}
        "|" 4 $* $+
        (L.L.vdv_kinderwagen)         {if} "W" {else} "|" 26 $* {endif} $+
        (S.$.vdv_symbole)
                
        1
        35
        72
        l1
        0
        0
        (L.$.vdv_symbole)
        (M.V.STTextOut)
        
'       Symbole unten rechts
        "|" 40 $*
        (L.L.engine_tank_content) 50 <       {if} "||||T" $+ {endif}
        (L.L.cockpit_light_feststellbremse)  {if} "||||P" $+ {endif}
        (S.$.vdv_symbole)
        l1 (M.V.TextLength) s2
                
        1
        158 l2 -
        72
        l1
        0
        0
        (L.$.vdv_symbole)
        (M.V.STTextOut)
        
        
'       ALMEX-Text
        "X10_vdv_text" (M.V.GetFontIndex) s1
        
        1
        3
        99
        l1
        0
        0
        (L.$.ALMEX_CockpitLine1)
        (M.V.STTextOut)
        
        1
        3
        115
        l1
        0
        0
        (L.$.ALMEX_CockpitLine2)
        (M.V.STTextOut)
    {endif}
    
    
'   Modus 2: Standmodus (Bus-Symbol)
    (L.L.vdv_mode) 2 =
    {if}
        "X10_vdv_symbole_32" (M.V.GetFontIndex) s1
        
        (L.L.vdv_initstate) 0 =
        {if}          
'           Bus-Symbol

            1
            19
            9
            l1
            0
            0
            "_"
            (M.V.STTextOut)
        {endif}
        
        "X10_vdv_symbole_20" (M.V.GetFontIndex) s1 
            
'       ausgefüllte Reifen (Haltestellenbremse)
        (L.L.bremse_halte) {if} ")" {else} "(" {endif}
    
        1
        41
        34
        l1
        0
        0
        
        (M.V.STTextOut)
        
        (L.L.bremse_halte) {if} ")" {else} "(" {endif}
    
        1
        101
        34
        l1
        0
        0
        
        (M.V.STTextOut)
        
        (L.L.bremse_halte) {if} ")" {else} "(" {endif}
        1
        115
        34
        l1
        0
        0
        
        (M.V.STTextOut)
        
        (L.L.vdv_initstate) 1 =
        {if}
'           Kneeling-Pfeile
            
            (L.L.kneel_upsound) (L.L.kneel_downsound) || (L.L.vdv_blink) ! && {if} "^" {else} "|" 10 $* {endif}
        
            1
            41
            47
            l1
            0
            0
            
            (M.V.STTextOut)
            
            (L.L.kneel_upsound) (L.L.kneel_downsound) || (L.L.vdv_blink) ! && {if} "^" {else} "|" 10 $* {endif}
        
            1
            101
            47
            l1
            0
            0
            
            (M.V.STTextOut)
            
            (L.L.kneel_upsound) (L.L.kneel_downsound) || (L.L.vdv_blink) ! && {if} "^" {else} "|" 10 $* {endif}
        
            1
            115
            47
            l1
            0
            0
            
            (M.V.STTextOut)
            
'           Türen
            (L.L.cp_tuerfluegelsperre_sw) -1 =
            (L.L.vdv_doorstate_0) ! &&
            {if}
                1
                24
                15
                l1
                0
                0
                "X"
                (M.V.STTextOut)
            
                (L.L.vdv_doorstate_1) {if} "\" {else} "/" {endif}
                1
                32
                15
                l1
                0
                0
                
                (M.V.STTextOut)
            {else}
            (L.L.cp_tuerfluegelsperre_sw) 1 =
            (L.L.vdv_doorstate_1) ! &&
            {if}
                1
                32
                15
                l1
                0
                0
                "X"
                (M.V.STTextOut)
            
                (L.L.vdv_doorstate_0) {if} "\" {else} "/" {endif}
            
                1
                24
                15
                l1
                0
                0
                
                (M.V.STTextOut)
            {else}
                (L.L.vdv_doorstate_0) {if} "]" {else} "[" {endif}
            
                1
                24
                15
                l1
                0
                0
                
                (M.V.STTextOut)
            {endif}
            {endif}
            
            (L.L.vdv_doorstate_23) s0 {if} "]" {else} "[" {endif}
            l0 !
            (L.L.vdv_freigabe) &&
            (L.L.vdv_blink) &&
            {if}
                "|" 16 $*
            {endif}
            
            1
            82
            15
            l1
            0
            0
            
            (M.V.STTextOut)
            
            (L.L.vdv_doorstate_45) s0 {if} "]" {else} "[" {endif}
            l0 !
            (L.L.vdv_freigabe) &&
            (L.L.vdv_blink) &&
            {if}
                "|" 16 $*
            {endif}
            
            1
            127
            15
            l1
            0
            0
            
            (M.V.STTextOut)
            
'           Rampen
            (L.L.door_rampe_1_active) {if} ">" {else} "<" {endif}
            
            1
            24
            35
            l1
            0
            0
            
            (M.V.STTextOut)
            
            (L.L.door_rampe_2_active) {if} ">" {else} "<" {endif}
            
            1
            82
            35
            l1
            0
            0
            
            (M.V.STTextOut)
        {endif}
    {endif}
    
'   Modus 3: Bremsdruck/Vorratsdruck:
    (L.L.vdv_mode) 3 =
    {if}
        "X10_vdv_symbole_20" (M.V.GetFontIndex) s1
        
        1
        4
        8
        l1
        0
        0
        "B"
        (M.V.STTextOut)
        
        "X10_vdv_symbole_63" (M.V.GetFontIndex) s1
        
        1
        4
        35
        l1
        0
        0
        "9"
        (M.V.STTextOut)
        
        "X10_vdv_text" (M.V.GetFontIndex) s1
        
        1
        34
        3
        l1
        0
        0
        "Bremsdruck"
        (M.V.STTextOut)
        
        1
        34
        100
        l1
        0
        0
        "Vorratsdruck"
        (M.V.STTextOut)
        
'       Balken 1 - Bremsdruck Kreis 1
        (L.L.bremse_p_Brzyl_HA) 0.00008083333 * 97 min trunc s0
        
        1
        24
        38
        24 l0 +
        44
        (M.V.STDrawRect)
        
'       Balken 2 - Bremsdruck Kreis 2
        (L.L.bremse_p_Brzyl_VA) 0.00008083333 * 97 min trunc s0
        
        1
        24
        49
        24 l0 +
        55
        (M.V.STDrawRect)
        
'       Balken 3 - Vorratsdruck Kreis 1
        (L.L.bremse_p_Tank01) 0.00008083333 * 97 min trunc s0
        
        1
        24
        78
        24 l0 +
        84
        (M.V.STDrawRect)
        
'       Balken 4 - Vorratsdruck Kreis 2
        (L.L.bremse_p_Tank02) 0.00008083333 * 97 min trunc s0
        
        1
        24
        89
        24 l0 +
        95
        (M.V.STDrawRect)
    {endif}
    
'   Modus 4: Kraftstoff:
    (L.L.vdv_mode) 4 =
    {if}
        "X10_vdv_symbole_20" (M.V.GetFontIndex) s1
        
        1
        7
        41
        l1
        0
        0
        "K"
        (M.V.STTextOut)
        
        "X10_vdv_symbole_27" (M.V.GetFontIndex) s1
        
        1
        14
        71
        l1
        0
        0
        "6"
        (M.V.STTextOut)
        
        "X10_vdv_text" (M.V.GetFontIndex) s1
        
        1
        34
        36
        l1
        0
        0
        "Kraftstoff"
        (M.V.STTextOut)
        
        133 (L.L.tank_percent) * trunc s0
        
        1
        16
        88
        16 l0 +
        95
        (M.V.STDrawRect)
        
    {endif}
    
'   Modus 5: Druck/Temperatur:
    (L.L.vdv_mode) 5 =
    {if}
        "X10_vdv_symbole_20" (M.V.GetFontIndex) s1
        
        1
        4
        8
        l1
        0
        0
        "D"
        (M.V.STTextOut)
        
        1
        4
        104
        l1
        0
        0
        "T"
        (M.V.STTextOut)
        
        "X10_vdv_symbole_27" (M.V.GetFontIndex) s1
        
        1
        14
        38
        l1
        0
        0
        "7"
        (M.V.STTextOut)
        
        1
        14
        70
        l1
        0
        0
        "8"
        (M.V.STTextOut)
        
        "X10_vdv_text" (M.V.GetFontIndex) s1
        
        1
        34
        3
        l1
        0
        0
        "Druck"
        (M.V.STTextOut)
        
        1
        34
        100
        l1
        0
        0
        "Temperatur"
        (M.V.STTextOut)
        
'       Balken 2 - Temperatur
        (L.L.engine_temperature) 0.925 * 148 min trunc s0
        
        1
        16
        88
        16 l0 +
        95
        (M.V.STDrawRect)
    {endif}
    
'   Modi 6-8: Bremsbelagdicke
    (L.L.vdv_mode) 6 =
    (L.L.vdv_mode) 7 = ||
    (L.L.vdv_mode) 8 = ||
    {if}        
        "X10_vdv_symbole_27" (M.V.GetFontIndex) s1
        
        1
        14
        38
        l1
        0
        0
        "6"
        (M.V.STTextOut)
        
        1
        14
        70
        l1
        0
        0
        "6"
        (M.V.STTextOut)
        
        "X10_vdv_text" (M.V.GetFontIndex) s1
        
        1
        10
        3
        l1
        0
        0
        "Bremsbelagdicke"
        (M.V.STTextOut)
        
        (L.L.vdv_mode) 6 = {if} "Vorderachse re." {endif}
        (L.L.vdv_mode) 7 = {if} "Triebachse re." {endif}
        (L.L.vdv_mode) 8 = {if} "Nachlaufachse re." {endif}
        
        1
        10
        19
        l1
        0
        0
        
        (M.V.STTextOut)
        
        (L.L.vdv_mode) 6 = {if} "Vorderachse li." {endif}
        (L.L.vdv_mode) 7 = {if} "Triebachse li." {endif}
        (L.L.vdv_mode) 8 = {if} "Nachlaufachse li." {endif}
        
        1
        10
        100
        l1
        0
        0
        
        (M.V.STTextOut)
    {endif}
    
'   Modus 99: Willkommen bei MAN
    (L.L.vdv_mode) 99 =
    {if}
        "X10_vdv_text" (M.V.GetFontIndex) s1
        
        1
        3
        22
        l1
        0
        0
        "   Willkommen bei   "
        (M.V.STTextOut)
        
        "X10_vdv_symbole_73" (M.V.GetFontIndex) s1
        
        1
        5
        45
        l1
        0
        0
        "M"
        (M.V.STTextOut)
    {endif}
    
    
'   Mipmaps erzeugen und unlocken
    1 (M.V.STUnlock)
    1 (M.V.STFilter)
    1 (M.V.STLock)
    1 (M.V.STUnlock)
    1 (M.V.STFilter)
{endif}
    
{end}
