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

'Simuliert alle unmittelbar mit dem Armaturenbrett zusammenhängenden Funktionen

'(c) 23.10.2009 Rüdiger Hülsmann
'(c) 03.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

'NrSpecRandom Seed Area:
'350...355

'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
'- Marcel Kuhnt		02.11.2012	Türentriegelungs-Leuchtmelder für drei Türen
'- Marcel Kuhnt		03.11.2012	Andere Klappfensterbezeichnungen und nur vier Stück
'- Marcel Kuhnt		04.11.2012	Zweite Türkontrolle
'- Marcel Kuhnt		22.03.2013	Hinzugefügt: Schalter Hublift & Knickschutz-Override
'- Marcel Kuhnt		11.09.2013	Dachluken
'- Marcel Kuhnt		14.10.2013	Neues Heizgerät für NL/NG eingebaut, Klimator- und Wagenlüfter werden im Heizungs-Script simuliert
'- Rüdiger Hülsmann	26.10.2013	Kneeling-Funktion
'- Marcel Kuhnt		08.11.2013	Hublift-Masterschalter


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


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

{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) (S.L.cockpit_gangN)	
		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_N}
	(L.L.antrieb_getr_gangvorwahl) 1 = !
	(L.L.cockpit_gangR) 0.7 = ||
	{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) (S.L.cockpit_gangD)
{end}

{trigger:automatic_N_off}
	(C.L.ZF_Gearbox)
	{if}
		(L.L.cockpit_gangN)
		{if}
			0.7 (S.L.cockpit_gangN)
		{endif}
	{else}
		0 (S.L.cockpit_gangN)
	{endif}
{end}

{trigger:automatic_1}
	(L.L.antrieb_getr_gangvorwahl) 0 >
	(L.L.cockpit_gangR) 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_gangN) (S.L.cockpit_gang2) (S.L.cockpit_gang3) (S.L.cockpit_gangD)
	{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 >
	(L.L.cockpit_gangR) 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_gangN) (S.L.cockpit_gang1) (S.L.cockpit_gang3) (S.L.cockpit_gangD)
	{endif}
{end}

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

{trigger:automatic_3}
	(C.L.cockpit_gear_3)
	{if}
		(L.L.antrieb_getr_gangvorwahl) 0 >
		(L.L.cockpit_gangR) 0 = &&
		(C.L.cockpit_gear_D_only) ! &&
		{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_gangN) (S.L.cockpit_gang1) (S.L.cockpit_gang2) (S.L.cockpit_gangD)
		{endif}
	{endif}
{end}

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

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

{trigger:automatic_D_off}
	(L.L.cockpit_gangD) 1 =
	{if}
		0.7 (S.L.cockpit_gangD)
	{endif}
{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_gong_toggle}
	(L.L.Telma-Bell) 1 =
	{if}
		(L.L.cockpit_gong) ! (L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
		{if}
			1 (S.L.cockpit_gong)
		{endif}
		(T.L.ev_kippschalter_ein)
		1 (S.L.cp_gong)
	{endif}
{end}

{trigger:cp_gong_toggle_off}
	(L.L.Telma-Bell) 1 =
	{if}
		(L.L.cockpit_gong) (L.L.elec_busbar_main) (C.L.elec_busbar_minV) > &&
		{if}
			0 (S.L.cockpit_gong)
		{endif}
		(T.L.ev_kippschalter_aus)
		0 (S.L.cp_gong)
	{endif}
{end}

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

{trigger:RetarderCap_toggle}
	(L.L.RetarderCap) ! (S.L.RetarderCap) s1
{end}

{trigger:cp_retarder_toggle}
	(C.L.EMI)
	{if}
		(L.L.cp_retarder_sw) ! (S.L.cp_retarder_sw) s1
		(M.L.kippschaltersound)
	{else}
		(L.L.cp_retarder_sw) ! (S.L.cp_retarder_sw)
		1 (S.L.cp_retarder)
		(T.L.ev_tuertaster_ein)
	{endif}
{end}

{trigger:cp_retarder_toggle_off}
	(C.L.EMI) !
	{if}
		(L.L.cp_retarder_sw) !
		{if}
			0.6 (S.L.cp_retarder)
		{else}
			0 (S.L.cp_retarder)
		{endif}
		(T.L.ev_tuertaster_aus)
	{endif}
{end}

{trigger:Telma_Retarder_drag}
	(L.S.mouse_y) 100 / (L.L.cp_Telma_Retarder_Hebel) + 0 max 1 min (S.L.cp_Telma_Retarder_Hebel) s0
	l0 0.2 <
	{if}
		0 (S.L.Telma_Retarder_mode) (S.L.antrieb_retarder_sw_direkt)
	{else}
		l0 0.4 <
		{if}
			1 (S.L.Telma_Retarder_mode) (S.L.antrieb_retarder_sw_direkt)
		{else}
			l0 0.6 <
			{if}
				2 (S.L.Telma_Retarder_mode)
				1 (S.L.antrieb_retarder_sw_direkt)
			{else}
				l0 0.8 <
				{if}
					3 (S.L.Telma_Retarder_mode)
					1 (S.L.antrieb_retarder_sw_direkt)
				{else}
					4 (S.L.Telma_Retarder_mode)
					1 (S.L.antrieb_retarder_sw_direkt)
				{endif}
			{endif}
		{endif}
	{endif}
{end}

{trigger:Telma_Retarder_off}
	(L.L.Telma_Retarder_mode) 4 / (S.L.cp_Telma_Retarder_Hebel)
	{if}
		(T.L.ev_wischerhebel)
	{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.kippschaltersound)
	{endif}
{end}

{trigger:cp_fahrerlicht_toggle}
	(L.L.cp_fahrerlicht) ! (S.L.cp_fahrerlicht)
	1 (S.L.cp_fahrerlicht_sw)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_fahrerlicht_toggle_off}
	(L.L.cp_fahrerlicht)
	{if}
		0.6 (S.L.cp_fahrerlicht_sw)
	{else}
		0 (S.L.cp_fahrerlicht_sw)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_TicketTable_toggle}
	(L.L.cp_TicketTable) ! (S.L.cp_TicketTable)
	1 (S.L.cp_TicketTable_sw)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_TicketTable_toggle_off}
	(L.L.cp_TicketTable)
	{if}
		0.6 (S.L.cp_TicketTable_sw)
	{else}
		0 (S.L.cp_TicketTable_sw)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_licht_untenrechts_toggle}
	(L.L.cp_licht_untenrechts) ! (S.L.cp_licht_untenrechts)
	1 (S.L.cp_licht_untenrechts_sw)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_licht_untenrechts_toggle_off}
	(L.L.cp_licht_untenrechts)
	{if}
		0.6 (S.L.cp_licht_untenrechts_sw)
	{else}
		0 (S.L.cp_licht_untenrechts_sw)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_licht_oberdeck_toggle}
	(L.L.cp_licht_oberdeck) ! (S.L.cp_licht_oberdeck)
	1 (S.L.cp_licht_oberdeck_sw)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_licht_oberdeck_toggle_off}
	(L.L.cp_licht_oberdeck)
	{if}
		0.6 (S.L.cp_licht_oberdeck_sw)
	{else}
		0 (S.L.cp_licht_oberdeck_sw)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_licht_unterdeck_toggle}
	(L.L.cp_licht_unterdeck) ! (S.L.cp_licht_unterdeck)
	1 (S.L.cp_licht_unterdeck_sw)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_licht_unterdeck_toggle_off}
	(L.L.cp_licht_unterdeck)
	{if}
		0.6 (S.L.cp_licht_unterdeck_sw)
	{else}
		0 (S.L.cp_licht_unterdeck_sw)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_licht_nebelschw_sw}
	(L.L.cp_licht_nebelschw_sw) 
	{if}
		0 (S.L.cp_licht_nebelschw_sw) s1
	{else}
		1 (S.L.cp_licht_nebelschw_sw) s1
	{endif}		
	(M.L.kippschaltersound)
{end}

{trigger:cp_wischer_schnell_toggle}
	(L.L.cp_wischer_schnell_sw) ! (S.L.cp_wischer_schnell_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:kw_wipermode_up}
	(L.L.cp_wischer_einaus_sw) ! (S.L.cp_wischer_einaus_sw) s1
	{if}
		2 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
		2 3 / (S.L.cockpit_wischerhebel) (S.L.cockpit_wischer_drehschalter)
		(L.L.cp_wischer_intervall_sw) !
		{if}
			(T.L.ev_wischerhebel)
		{endif}
	{else}
		(L.L.cp_wischer_intervall_sw)
		{if}
			1 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
			1 3 / (S.L.cockpit_wischerhebel) 
			0 (S.L.cockpit_wischer_drehschalter)
		{else}
			0 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischerhebel) 
			1 3 / (S.L.cockpit_wischer_drehschalter)
			(T.L.ev_wischerhebel)
		{endif}
	{endif}
	(C.L.wiper_lever) !
	{if}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_wischer_intervall_toggle}
	(L.L.cp_wischer_intervall_sw) ! (S.L.cp_wischer_intervall_sw) s1
	(L.L.cp_wischer_einaus_sw) ! &&
	{if}
		1 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
		1 3 / (S.L.cockpit_wischerhebel) 
		0 (S.L.cockpit_wischer_drehschalter)
	{else}
		(L.L.cp_wischer_einaus_sw)
		{if}
			2 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode)
			2 3 / (S.L.cockpit_wischerhebel) (S.L.cockpit_wischer_drehschalter)
		{else}
			0 (S.L.cockpit_wischerhebel_mode) (S.L.cockpit_wischer_drehschalter_mode) (S.L.cockpit_wischerhebel)
			1 3 / (S.L.cockpit_wischer_drehschalter)
		{endif}

	{endif}
	(C.L.wiper_lever) !
	{if}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_wischer_wascher_button}
	1 (S.L.cp_wischer_wascher_sw) s1
	(C.L.wiper_lever)
	{if}
		(T.L.ev_wischerhebel)
		1 (S.L.cockpit_wischerhebel_x)
	{else}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

{trigger:cp_wischer_wascher_button_off}
	0 (S.L.cp_wischer_wascher_sw) s1
	(S.L.wiper_wascher_sw)
	(C.L.wiper_lever)
	{if}
		(T.L.ev_wischerhebel)
		0 (S.L.cockpit_wischerhebel_x)
	{else}
		l1 (M.L.kippschaltersound)
	{endif}
{end}

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

{trigger:cp_heizluefter_drag}
	(L.S.mouse_y) -100 / (L.L.cp_heizluefter_sw) + (S.L.cp_heizluefter_sw) s0
	l0 0 <
	{if}
		0 (S.L.cp_heizluefter_sw)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_heizluefter_sw)
	{endif}
{end}

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

{trigger:cp_IndicatorLightControl_toggle}
	1 (S.L.cp_IndicatorLightControl_sw) s1
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_IndicatorLightControl_toggle_off}
	0 (S.L.cp_IndicatorLightControl_sw) s1
	(T.L.ev_tuertaster_aus)
{end}

{trigger:PassengerDanger}
	1 (S.L.cp_taster_Danger)
{end}

{trigger:PassengerDanger_off}
	0 (S.L.cp_taster_Danger)
{end}

{trigger:PassengerDanger_Cancel}
	(L.L.PassengerDanger_Cancel) ! (S.L.PassengerDanger_Cancel)
	1 (S.L.PassengerDanger_Cancel_sw)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:PassengerDanger_Cancel_off}
	(L.L.PassengerDanger_Cancel)
	{if}
		0.6 (S.L.PassengerDanger_Cancel_sw)
	{else}
		0 (S.L.PassengerDanger_Cancel_sw)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

'--------------------------------------------------------
'Dummys:

{trigger:cp_dummy_sw01_toggle}
	(L.L.cp_dummy_sw01) ! (S.L.cp_dummy_sw01)
	1 (S.L.cp_dummy_func01)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_dummy_sw01_toggle_off}
	(L.L.cp_dummy_sw01)
	{if}
		0.6 (S.L.cp_dummy_func01)
	{else}
		0 (S.L.cp_dummy_func01)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_dummy_sw02_toggle}
	(L.L.cp_dummy_sw02) ! (S.L.cp_dummy_sw02)
	1 (S.L.cp_dummy_func02)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_dummy_sw02_toggle_off}
	(L.L.cp_dummy_sw02)
	{if}
		0.6 (S.L.cp_dummy_func02)
	{else}
		0 (S.L.cp_dummy_func02)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_dummy_sw03_toggle}
	(L.L.cp_dummy_sw03) ! (S.L.cp_dummy_sw03)
	1 (S.L.cp_dummy_func03)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_dummy_sw03_toggle_off}
	(L.L.cp_dummy_sw03)
	{if}
		0.6 (S.L.cp_dummy_func03)
	{else}
		0 (S.L.cp_dummy_func03)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_dummy_sw04_toggle}
	(L.L.cp_dummy_sw04) ! (S.L.cp_dummy_sw04)
	1 (S.L.cp_dummy_func04)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_dummy_sw04_toggle_off}
	(L.L.cp_dummy_sw04)
	{if}
		0.6 (S.L.cp_dummy_func04)
	{else}
		0 (S.L.cp_dummy_func04)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_dummy_sw05_toggle}
	(L.L.cp_dummy_sw05) ! (S.L.cp_dummy_sw05)
	1 (S.L.cp_dummy_func05)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_dummy_sw05_toggle_off}
	(L.L.cp_dummy_sw05)
	{if}
		0.6 (S.L.cp_dummy_func05)
	{else}
		0 (S.L.cp_dummy_func05)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

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

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

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

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

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

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

{trigger:cp_schalter_hub_up_toggle}
	1 (S.L.cp_hub_up_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_hub_up_toggle_off}
	0 (S.L.cp_hub_up_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_hub_dn_toggle}
	1 (S.L.cp_hub_dn_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_hub_dn_toggle_off}
	0 (S.L.cp_hub_dn_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_hub_mstr_toggle}
	(L.L.cp_hub_mstr_sw) ! (S.L.cp_hub_mstr_sw) 0 s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_knick_ovrd_toggle}
	1 (S.L.cp_knick_ovrd_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_schalter_knick_ovrd_toggle_off}
	0 (S.L.cp_knick_ovrd_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_klimator_sw_drag}
	(L.S.mouse_y) -100 / (L.L.cp_klimator_sw) + (S.L.cp_klimator_sw) s0
	l0 0 <
	{if}
		0 (S.L.cp_klimator_sw)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_klimator_sw)
	{endif}
{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}

{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}
'	Fallunterscheidung: Schlüssel in x- oder y-Richtung?
	
	(L.S.mouse_y) abs (L.S.mouse_x) abs >=
	{if}

'		Sonst Rotation (Lichtschalter)

		(L.S.mouse_x) -20 / (L.L.cp_schluessel_rot) + 0 max 1 min (S.L.cp_schluessel_rot) s1

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

		l1 0.2 <
		{if}
			0 (S.L.cp_schluessel_rot_mode) 
		{else} 
			l1 0.8 <
			{if}
				1 (S.L.cp_schluessel_rot_mode) 
			{else}
				2 (S.L.cp_schluessel_rot_mode)
			{endif}
		{endif}
	{endif}
{end}

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

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

{trigger:cp_batterietrennschalter_toggle}
	(L.L.cp_taster_batterietrennschalter) ! (S.L.cp_taster_batterietrennschalter)
	1 (S.L.elec_busbar_main_sw)
	(T.L.ev_tuertaster_ein)
{end}
			
{trigger:cp_batterietrennschalter_toggle_off}
	(L.L.cp_taster_batterietrennschalter)
	{if}
		0.6 (S.L.elec_busbar_main_sw)
	{else}
		0 (S.L.elec_busbar_main_sw)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

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

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

{trigger:cp_klappfenster_3}
	(L.L.cp_klappfenster_3) ! (S.L.cp_klappfenster_3) s1
	(M.L.klappfenstersound_T)
{end}

{trigger:cp_klappfenster_4}
	(L.L.cp_klappfenster_4) ! (S.L.cp_klappfenster_4) s1
	(M.L.klappfenstersound_T)
{end}

{trigger:cp_klappfenster_5}
	(L.L.cp_klappfenster_5) ! (S.L.cp_klappfenster_5) s1
	(M.L.klappfenstersound_T)
{end}

{trigger:cp_klappfenster_6}
	(L.L.cp_klappfenster_6) ! (S.L.cp_klappfenster_6) s1
	(M.L.klappfenstersound_T)
{end}


{trigger:cp_dachluke_1}
	(L.L.cp_dachluke_1) 1 + (S.L.cp_dachluke_1) 3 >
	{if}
		0 (S.L.cp_dachluke_1)
	{endif}
	(L.L.cp_dachluke_1) s0
	(M.L.dachluke_pos_rot)
	l1 (S.L.cp_dachluke_1_pos)
	l2 (S.L.cp_dachluke_1_rot)
	l3 (S.L.cp_dachluke_1_S1)
	l4 (S.L.cp_dachluke_1_S2)
{end}

{trigger:cp_dachluke_2}
	(L.L.cp_dachluke_2) 1 + (S.L.cp_dachluke_2) 3 >
	{if}
		0 (S.L.cp_dachluke_2)
	{endif}
	(L.L.cp_dachluke_2) s0
	(M.L.dachluke_pos_rot)
	l1 (S.L.cp_dachluke_2_pos)
	l2 (S.L.cp_dachluke_2_rot)
	l3 (S.L.cp_dachluke_2_S1)
	l4 (S.L.cp_dachluke_2_S2)
{end}

{trigger:cp_dachluke_3}
	(L.L.cp_dachluke_3) 1 + (S.L.cp_dachluke_3) 3 >
	{if}
		0 (S.L.cp_dachluke_3)
	{endif}
	(L.L.cp_dachluke_3) s0
	(M.L.dachluke_pos_rot)
	l1 (S.L.cp_dachluke_3_pos)
	l2 (S.L.cp_dachluke_3_rot)
	l3 (S.L.cp_dachluke_3_S1)
	l4 (S.L.cp_dachluke_3_S2)
{end}

{trigger:cp_dachluke_4}
	(L.L.cp_dachluke_4) 1 + (S.L.cp_dachluke_4) 3 >
	{if}
		0 (S.L.cp_dachluke_4)
	{endif}
	(L.L.cp_dachluke_4) s0
	(M.L.dachluke_pos_rot)
	l1 (S.L.cp_dachluke_4_pos)
	l2 (S.L.cp_dachluke_4_rot)
	l3 (S.L.cp_dachluke_4_S1)
	l4 (S.L.cp_dachluke_4_S2)
{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:cp_Hatch1_drag}
	1 (S.L.cp_Hatch1_dragged)
	(L.L.cp_Hatch1_pos) (S.L.cp_Hatch1_lastpos)

	(L.S.mouse_x) 500 / (L.L.cp_Hatch1_pos) + (S.L.cp_Hatch1_pos) s0
	l0 0 <
	{if}
		0 (S.L.cp_Hatch1_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_Hatch1_pos)
	{endif}
	(L.L.cp_Hatch1_pos) (L.L.cp_Hatch1_lastpos) - (L.S.Timegap) / (S.L.cp_Hatch1_speed)
{end}

{trigger:cp_Hatch1_off}
	0 (S.L.cp_Hatch1_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:taster_standheizung}
	(L.L.cp_taster_standheizung_target) ! (S.L.cp_taster_standheizung_target) s1

	1 (S.L.cp_taster_standheizung)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:taster_standheizung_off}
	(L.L.cp_taster_standheizung_target)
	{if}
		0.6 (S.L.cp_taster_standheizung)
	{else}
		0 (S.L.cp_taster_standheizung)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:taster_nebelschluss}
	(L.L.cp_taster_nebelschluss_target) ! (S.L.cp_taster_nebelschluss_target)
	(L.L.cp_taster_nebelschluss2_target) ! (S.L.cp_taster_nebelschluss2_target)

	1 (S.L.cp_taster_nebelschluss)
	1 (S.L.cp_taster_nebelschluss2)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:taster_nebelschluss_off}
	(L.L.cp_taster_nebelschluss_target)
	{if}
		0.6 (S.L.cp_taster_nebelschluss)
	{else}
		0 (S.L.cp_taster_nebelschluss)
	{endif}

	(L.L.cp_taster_nebelschluss2_target)
	{if}
		0.6 (S.L.cp_taster_nebelschluss2)
	{else}
		0 (S.L.cp_taster_nebelschluss2)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:taster_nebelschluss2}
	(L.L.cp_taster_nebelschluss_target) ! (S.L.cp_taster_nebelschluss_target)

	1 (S.L.cp_taster_nebelschluss)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:taster_nebelschluss2_off}
	(L.L.cp_taster_nebelschluss_target)
	{if}
		0.6 (S.L.cp_taster_nebelschluss)
	{else}
		0 (S.L.cp_taster_nebelschluss)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:taster_nebelschluss3}
	(L.L.cp_taster_nebelschluss2_target) ! (S.L.cp_taster_nebelschluss2_target)

	1 (S.L.cp_taster_nebelschluss2)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:taster_nebelschluss3_off}
	(L.L.cp_taster_nebelschluss2_target)
	{if}
		0.6 (S.L.cp_taster_nebelschluss2)
	{else}
		0 (S.L.cp_taster_nebelschluss2)
	{endif}
	(T.L.ev_tuertaster_aus)
{end}

{trigger:cp_wiperlever_drag}
'	Fallunterscheidung: Hebel in x- oder y-Richtung?

	(C.L.wiper_lever)
	{if}
		(L.S.mouse_y) abs (L.S.mouse_x) abs >=
		{if}
			(L.S.mouse_y) -50 / (L.L.cockpit_wischerhebel) + 0 max 1 min (S.L.cockpit_wischerhebel) s0
		
'			Stufen:
'			0: Aus
'			1: Intervall
'			2: Langsam
'			3: Schnell

			l0 0.17 <
			{if}
				0 (S.L.cockpit_wischerhebel_mode) (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
			{else} 
				l0 0.5 <
				{if}
					1 (S.L.cockpit_wischerhebel_mode) (S.L.cp_wischer_intervall_sw)
					0 (S.L.cp_wischer_schnell_sw) (S.L.cp_wischer_einaus_sw)
				{else}
					l0 0.83 <
					{if}
						2 (S.L.cockpit_wischerhebel_mode)
						1 (S.L.cp_wischer_einaus_sw)
						0 (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_schnell_sw)
					{else}
						3 (S.L.cockpit_wischerhebel_mode)
						1 (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
						0 (S.L.cp_wischer_intervall_sw)
					{endif}
				{endif}
			{endif}
		{else}
			(L.S.mouse_x) 50 / (L.L.cockpit_wischerhebel_x) + 0 max 1 min (S.L.cockpit_wischerhebel_x) s1

'			Waschanlage (Hebel nach oben)	
			l1 0.9 >
			{if}
				(L.L.cp_wischer_wascher_sw) !
				{if}
					(T.L.ev_wischerhebel)
				{endif}
				1 (S.L.cp_wischer_wascher_sw)
			{else}
				(L.L.cp_wischer_wascher_sw)
				{if}
					(T.L.ev_wischerhebel)
				{endif}
				0 (S.L.cp_wischer_wascher_sw)
			{endif}
		{endif}
	{endif}
{end}

{trigger:cp_wiperlever_off}
'	Einrasten auf den festen Positionen:
	(L.L.cockpit_wischerhebel_mode) 3 / (S.L.cockpit_wischerhebel)
	(L.L.cp_wischer_wascher_sw)
	{if}
		(T.L.ev_wischerhebel)
		0 (S.L.cockpit_wischerhebel_x) (S.L.cp_wischer_wascher_sw)
	{endif}
{end}

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

		l0 0.17 <
		{if}
			1 (S.L.cp_wischer_intervall_sw)
			0 (S.L.cockpit_wischer_drehschalter_mode) (S.L.cp_wischer_schnell_sw) (S.L.cp_wischer_einaus_sw)		
		{else} 
			l0 0.5 <
			{if}
				0 (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
				1 (S.L.cockpit_wischer_drehschalter_mode)
			{else}
				l0 0.83 <
				{if}
					2 (S.L.cockpit_wischer_drehschalter_mode)
					1 (S.L.cp_wischer_einaus_sw)
					0 (S.L.cp_wischer_intervall_sw) (S.L.cp_wischer_schnell_sw)
				{else}
					3 (S.L.cockpit_wischer_drehschalter_mode)
					1 (S.L.cp_wischer_einaus_sw) (S.L.cp_wischer_schnell_sw)
					0 (S.L.cp_wischer_intervall_sw)
				{endif}
			{endif}
		{endif}
'	{endif}
{end}

{trigger:cp_wiper_turnswitch_off}
'	Einrasten auf den festen Positionen:
	(L.L.cockpit_wischer_drehschalter_mode) 3 / (S.L.cockpit_wischer_drehschalter)
{end}
	
{trigger:cp_microphone}
	1 (S.L.cp_microphone_sw)
{end}

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

{trigger:cp_heizregler_defrost_Dn}
	(L.L.cockpit_heizregler_defrost) ! (S.L.cockpit_heizregler_defrost) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_heizregler_defrost_Up}
	(L.L.cockpit_heizregler_defrost) ! -1 (S.L.cockpit_heizregler_defrost) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_heizregler_defrost_Dn_off}
	0 (S.L.cockpit_heizregler_defrost)
	(M.L.kippschaltersound)
{end}

{trigger:cp_heizregler_defrost_Up_off}
	0 (S.L.cockpit_heizregler_defrost)
	(M.L.kippschaltersound)
{end}

{trigger:cp_heizregler_fussraum_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_fussraum) + 0 max 1 min (S.L.cockpit_heizregler_fussraum)
{end}

{trigger:cp_heizregler_temp_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_temp) + 0 max 1 min (S.L.cockpit_heizregler_temp)
{end}

{trigger:cp_heizregler_bug_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_bug) + 0 max 1 min (S.L.cockpit_heizregler_bug)
{end}

{trigger:cp_heizregler_umluft_Dn}
	(L.L.cockpit_heizregler_umluft) ! (S.L.cockpit_heizregler_umluft) s1
	0 (S.L.cockpit_heizregler_ventilation_mode)
	(M.L.kippschaltersound)
{end}

{trigger:cp_heizregler_umluft_Up}
	(L.L.cockpit_heizregler_umluft) ! -1 (S.L.cockpit_heizregler_umluft) s1
	2 (S.L.cockpit_heizregler_ventilation_mode)
	(M.L.kippschaltersound)
{end}

{trigger:cp_heizregler_umluft_Dn_off}
	0 (S.L.cockpit_heizregler_umluft)
	(M.L.kippschaltersound)
{end}

{trigger:cp_heizregler_umluft_Up_off}
	0 (S.L.cockpit_heizregler_umluft)
	(M.L.kippschaltersound)
{end}

{trigger:cp_heizregler_umluft_off}
	(L.L.cockpit_heizregler_ventilation_mode) 2 / (S.L.cockpit_heizregler_umluft)
{end}

{trigger:cp_aircon_sw_toggle}
	(L.L.cp_aircon_sw) ! (S.L.cp_aircon_sw) s1
	(M.L.kippschaltersound)
{end}

{trigger:cp_vis_MoneyChanger}
	(L.L.cp_vis_MoneyChanger) ! (S.L.cp_vis_MoneyChanger)
{end}

{trigger:cp_Fan_toggle}
	(L.L.cp_Fan) ! (S.L.cp_Fan)
	(L.L.Timer_Fan-Off) 0 = &&
	{if}
		1 (S.L.cp_Fan)
		(T.L.ev_Fan)
	{else}
		0 (S.L.cp_Fan)
		(L.L.Timer_Fan-Off) 1 =
		{if}
			(T.L.ev_Fan)
		{endif}
	{endif}
	1 (S.L.cp_sw_Fan)
	(T.L.ev_tuertaster_ein)
{end}

{trigger:cp_Fan_toggle_off}
(L.L.cp_Fan)
{if}
	0.6 (S.L.cp_sw_Fan)
{else}
	0 (S.L.cp_sw_Fan)
{endif}
	(T.L.ev_tuertaster_aus)
{end}


'**********************
'	HandBook
'**********************

{trigger:cp_handbook_toggle}
	(L.L.cp_handbook) ! (S.L.cp_handbook)
{end}

{trigger:cp_SidePillows_toggle}
	(L.L.cp_SidePillows) ! (S.L.cp_SidePillows)
	0 (S.L.SidePillows_loadvar)
	(M.L.SidePillows)
{end}

{trigger:cp_mirrors_toggle}
	(L.L.cp_Mirrors) ! (S.L.cp_Mirrors)
	0 (S.L.Mirrors_loadvar)
	(M.L.Mirrors)
{end}

{trigger:Ad-Left_toggle}
	(L.L.cp_Ad-Left) 1 + (S.L.cp_Ad-Left) 2 >
	{if}
		0 (S.L.cp_Ad-Left)
	{endif}
	0 (S.L.Ad-Left_loadvar)
	(M.L.Ads)
{end}

{trigger:Ad-Right_toggle}
	(L.L.cp_Ad-Right) 1 + (S.L.cp_Ad-Right) 2 >
	{if}
		0 (S.L.cp_Ad-Right)
	{endif}
	0 (S.L.Ad-Right_loadvar)
	(M.L.Ads)
{end}

{trigger:Ad-Back_toggle}
	(L.L.cp_Ad-Back) 1 + (S.L.cp_Ad-Back) 2 >
	{if}
		0 (S.L.cp_Ad-Back)
	{endif}
	0 (S.L.Ad-Back_loadvar)
	(M.L.Ads)
{end}

{trigger:cp_FrontFogLights_toggle}
	(L.L.cp_FrontFogLights) ! (S.L.cp_FrontFogLights)
	0 (S.L.FrontFogLights_loadvar)
	(M.L.FrontFogLights)
{end}

{trigger:cp_display_toggle}
	(L.L.cp_display) 1 + (S.L.cp_display) 6 >
	{if}
		0 (S.L.cp_display)
	{endif}
	0 (S.L.display_loadvar)
	(M.L.display)
{end}

{trigger:cp_IntDisplay_toggle}
	(L.L.cp_InteriorDisplay) ! (S.L.cp_InteriorDisplay)
	0 (S.L.InteriorDisplay_loadvar)
	(M.L.InteriorDisplay_load)
{end}

{trigger:cp_aircon_toggle}
	(L.L.cp_aircon) ! (S.L.cp_aircon)
	0 (S.L.aircon_loadvar)
	(M.L.aircon)
{end}

{trigger:cp_DoorControl_toggle}
	(L.L.AllDoorManual) ! (S.L.AllDoorManual)
	0 (S.L.AllDoorManual_loadvar)
	(M.L.AllDoorManual_load)
{end}

{trigger:cp_3rdWiper_toggle}
	(L.L.cp_3rdWiper) ! (S.L.cp_3rdWiper)
	0 (S.L.3rdWiper_loadvar)
	(M.L.3rdWiper)
{end}

{trigger:cp_Telma-Bell_toggle}
	(L.L.cp_Telma-Bell) 1 + (S.L.cp_Telma-Bell) 2 >
	{if}
		0 (S.L.cp_Telma-Bell)
	{endif}
	0 (S.L.Telma-Bell_loadvar)
	(M.L.Telma-Bell)
{end}

{trigger:cp_AdditionalMeter_toggle}
	(L.L.cp_AdditionalMeter) 1 + (S.L.cp_AdditionalMeter) 2 >
	{if}
		0 (S.L.cp_AdditionalMeter)
	{endif}
	0 (S.L.AdditionalMeter_loadvar)
	(M.L.AdditionalMeter)
{end}

{trigger:cp_Odometer_toggle}
	(L.L.cp_Odometer) ! (S.L.cp_Odometer)
	0 (S.L.Odometer_loadvar)
	(M.L.Odometer)
{end}

{trigger:cp_SteeringWheel_toggle}
	(L.L.cp_SteeringWheel) ! (S.L.cp_SteeringWheel)
	0 (S.L.SteeringWheel_loadvar)
	(M.L.SteeringWheel)
{end}

{trigger:cp_hubcaps_toggle}
	(L.L.cp_hubcaps) 1 + (S.L.cp_hubcaps) 2 >
	{if}
		0 (S.L.cp_hubcaps)
	{endif}
	0 (S.L.hubcaps_loadvar)
	(M.L.hubcaps)
{end}

{trigger:cp_Ticketprinter_toggle}
	(L.L.Ticketprinter) ! (S.L.Ticketprinter)
	0 (S.L.Ticketprinter_loadvar)
	(M.L.Ticketprinter)
{end}

{trigger:cp_ServicesPlates_toggle}
	(L.L.ServicePlate_selected) 1 + (S.L.ServicePlate_selected) 3 >
	{if}
		0 (S.L.ServicePlate_selected)
	{endif}
	0 (S.L.ServicesPlates_loadvar)
	(M.L.ServicesPlates)
{end}

{trigger:cp_WindPlates_toggle}
	(L.L.WindshieldPlate_selected) 1 + (S.L.WindshieldPlate_selected) 2 >
	{if}
		0 (S.L.WindshieldPlate_selected)
	{endif}
	0 (S.L.WindPlates_loadvar)
	(M.L.WindPlates)
{end}

{trigger:cp_Engine_PWR_mode_toggle}
	(L.L.cp_Engine_PWR_mode) ! (S.L.cp_Engine_PWR_mode)
	0 (S.L.Engine_PWR_mode_loadvar)
	(M.L.Engine_PWR_mode)
{end}

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

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

	(C.L.ZF_Gearbox)
	{if}
		0.7 (S.L.cockpit_gangN)
	{endif}

	4 (S.L.vis_display)
	1 (S.L.vis_FrontFogLights) (S.L.vis_3rdWiper) (S.L.vis_AdditionalMeter)
	2 (S.L.vis_Telma-Bell)

	(C.L.cockpit_zentralschmierung_dist) random (S.L.cp_zentralschmierung_nextkm)

	0.333 (S.L.cockpit_wischer_drehschalter)

	1 (S.L.SidePillows_loadvar) (S.L.Mirrors_loadvar) (S.L.Ad-Left_loadvar) (S.L.Ad-Right_loadvar) (S.L.Ad-Back_loadvar) (S.L.FrontFogLights_loadvar) (S.L.display_loadvar) (S.L.InteriorDisplay_loadvar) (S.L.aircon_loadvar) (S.L.AllDoorManual_loadvar) (S.L.3rdWiper_loadvar) (S.L.Telma-Bell_loadvar) (S.L.AdditionalMeter_loadvar) (S.L.Odometer_loadvar) (S.L.SteeringWheel_loadvar) (S.L.hubcaps_loadvar) (S.L.Ticketprinter_loadvar) (S.L.ServicesPlates_loadvar) (S.L.WindPlates_loadvar) (S.L.Engine_PWR_mode_loadvar)
{end}

'----------------------
'	Frame
'----------------------
{macro:cockpit_frame}
'Übertragen der Schalterstellungen:
	(L.L.cp_retarder_sw) (S.L.antrieb_retarder_sw)
	(L.L.cp_Telma-Bell) 2 = !
	{if}
		(L.L.cp_retarder_sw_direkt) (S.L.antrieb_retarder_sw_direkt)
	{endif}
	(L.L.cp_wischer_schnell_sw) (S.L.wiper_schnell_sw)
	(L.L.cp_wischer_einaus_sw) (S.L.wiper_einaus_sw)
	(L.L.cp_wischer_intervall_sw) (S.L.wiper_intervall_sw)
	(L.L.cp_wischer_wascher_sw) (S.L.wiper_wascher_sw)

	(M.L.tacho_frame)
	(M.L.uhr_frame)
	(M.L.drehzahlmesser_frame)
	(M.L.hupe_frame)
	(M.L.gong_frame)
	(M.L.blinkerhebel_frame)
	(M.L.wischerhebel_frame)
	(M.L.wischer_drehschalter_frame)
	(M.L.oeldruck_frame)
	(M.L.tankuhr_frame)
	(M.L.cockpitlights_frame)
	(M.L.klimator_frame)
	(M.L.schluessel_frame)
	(M.L.odometer_frame)
	(M.L.Digital_odometer_frame)
	(M.L.fahrertuer_frame) 
	(M.L.Hatch1_frame) 
	(M.L.rollo_frame)
	(M.L.engine_thermometer_frame)
	(M.L.microphone_frame)
	(M.L.pressure_warning_needle_frame)
	(M.L.zentralschmierung_frame)
	(M.L.Thermometer_frame)
	(M.L.phys_arms)
	(M.L.Telma_Retarder_frame)
	(M.L.Main_PressureWinkel)
	(M.L.Fan_frame)

	(M.L.SidePillows)
	(M.L.Mirrors)
	(M.L.Ads)
	(M.L.FrontFogLights)
	(M.L.display)
	(M.L.InteriorDisplay_load)
	(M.L.aircon)
	(M.L.AllDoorManual_load)
	(M.L.3rdWiper)
	(M.L.Telma-Bell)
	(M.L.AdditionalMeter)
	(M.L.Odometer)
	(M.L.SteeringWheel)
	(M.L.Hubcaps)
	(M.L.Ticketprinter)
	(M.L.ServicesPlates)
	(M.L.WindPlates)
	(M.L.Engine_PWR_mode)

	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	(L.L.engine_injection_on) ||
	(L.L.elec_failure_general) ! &&
	{if}
		(L.L.cockpit_gang1) (L.L.elec_busbar_main) * (S.L.cockpit_gang1_light)
		(L.L.cockpit_gang2) (L.L.elec_busbar_main) * (S.L.cockpit_gang2_light)
		(L.L.cockpit_gang3) (L.L.elec_busbar_main) * (S.L.cockpit_gang3_light)
		(L.L.cockpit_gangD) (L.L.elec_busbar_main) * (S.L.cockpit_gangD_light)
		(L.L.cockpit_gangN) (L.L.elec_busbar_main) * (S.L.cockpit_gangN_light)
		(L.L.cockpit_gangR) (L.L.elec_busbar_main) * (S.L.cockpit_gangR_light)
	{else}
		0 (S.L.cockpit_gang1_light) (S.L.cockpit_gang2_light) (S.L.cockpit_gang3_light) (S.L.cockpit_gangD_light) (S.L.cockpit_gangN_light) (S.L.cockpit_gangR_light)
	{endif}

	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	(L.L.elec_failure_general) ! &&
	{if}
		(L.L.door_0) 0.1 > (L.L.elec_busbar_main) * (S.L.cp_door_light_1-1)
		(L.L.door_1) 0.1 > (L.L.elec_busbar_main) * (S.L.cp_door_light_1-2)
		(L.L.door_0) 0.1 > (L.L.door_1) 0.1 > || (L.L.elec_busbar_main) * (S.L.cp_door_light_1)
		(L.L.door_2) 0.1 > (L.L.door_3) 0.1 > || (L.L.elec_busbar_main) * (S.L.cp_door_light_2)
		(L.L.door_4) 0.1 > (L.L.door_5) 0.1 > || (L.L.elec_busbar_main) * (S.L.cp_door_light_3)
		(L.L.door_6) 0.1 > (L.L.door_7) 0.1 > || (L.L.elec_busbar_main) * (S.L.cp_door_light_4)
		(L.L.door_8) 0.1 > (L.L.door_9) 0.1 > || (L.L.elec_busbar_main) * (S.L.cp_door_light_5)
		(L.L.door_2) 0.1 > (L.L.door_3) 0.1 > || (L.L.door_4) 0.1 > || (L.L.door_5) 0.1 > || (L.L.door_6) 0.1 > || (L.L.door_7) 0.1 > || (L.L.door_8) 0.1 > || (L.L.door_9) 0.1 > || (L.L.elec_busbar_main) * || || (S.L.cp_door_light_All)
		(L.L.door_20h_sw) (L.L.elec_busbar_main) * (S.L.cp_Light_Bus_20h)
	{else}
		0 (S.L.cp_door_light_1-1) (S.L.cp_door_light_1-2) (S.L.cp_door_light_1) (S.L.cp_door_light_2) (S.L.cp_door_light_3) (S.L.cp_door_light_4) (S.L.cp_door_light_5) (S.L.cp_door_light_All) (S.L.cp_Light_Bus_20h)
	{endif}
{end}

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

{macro:uhr_frame}
	(L.L.elec_busbar_avail) 0.5 >
	{if}
		(L.S.Time) s0 60 / (S.L.cockpit_uhr_min) 12 / (S.L.cockpit_uhr_std)
		l0 trunc (S.L.cockpit_uhr_sek)
	{endif}
{end} 

{macro:drehzahlmesser_frame}
	(L.L.engine_n) 3000 270 / / (S.L.cockpit_drehzahlwinkel)
{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:gong_frame}
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	{if}
		(L.S.GetTime) (L.L.gong_play_Timegap) - 0.769751 >=
		(L.L.cockpit_gong) &&
		{if}
			(T.L.Gong)
			(L.S.GetTime) (S.L.gong_play_Timegap)
		{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}
		1 (S.L.cockpit_fernlichthebel)
	{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:phys_arms}
	(L.L.A_Trans_X) 9.81 / (C.L.phys_arms_min) min (C.L.phys_arms_max) max (L.L.cp_latcharms) - (C.L.phys_arms_faktor) * (L.S.Timegap) / (L.S.Timegap) (C.L.phys_arms_speed) * /-/ exp (L.L.cp_latcharms_Speed) * + (S.L.cp_latcharms_Speed) (L.S.Timegap) * (L.L.cp_latcharms) + 
	(S.L.cp_latcharms) 
{end}

{macro:Telma_Retarder_frame}
	(L.L.Telma_Retarder_lastmode) (L.L.Telma_Retarder_mode) = !
	{if}
		(T.L.ev_wischerhebel)
	{endif}
	(L.L.Telma_Retarder_mode) (S.L.Telma_Retarder_lastmode)
{end}

{macro:cockpitlights_frame}
'	Cockpit test lights
	(L.L.EngineRunning)
	{if}
		(L.L.EngineRunning_Timer) (L.S.Timegap) + 10 min s0
	{else}
		0
	{endif}
	(S.L.EngineRunning_Timer)

	(L.L.engine_on)
	{if}
		1 (S.L.EngineRunning)
		l0 2 > l0 5 < && (S.L.CheckLights)
	{else}
		0 (S.L.CheckLights) (S.L.EngineRunning)
	{endif}

'	Red Alarm
	(L.L.CheckLights)
	(L.L.cockpit_light_masterfailure) ||
	(L.L.cockpit_light_MotorTemperature) ||
	(L.L.cp_IndicatorLightControl_sw) ||
	(L.L.elec_busbar_main) *
	(S.L.cockpit_light_AlarmMain)

'	Yellow Alarm
	(L.L.CheckLights)
	(L.L.cp_IndicatorLightControl_sw) ||
	(L.L.elec_busbar_main) *
	(S.L.cockpit_light_YellowAlarm)

'	Low Pressure
	(L.L.CheckLights)
	(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.cp_IndicatorLightControl_sw) ||
	(L.L.elec_busbar_main) *
	(S.L.cockpit_light_masterfailure)

'	Motor Temperature
	(L.L.engine_temperature) 100 >
	(L.L.cp_IndicatorLightControl_sw) ||
	(L.L.elec_busbar_main) *
	(S.L.cockpit_light_MotorTemperature)

'	Passenger Danger Button
	(L.L.cp_taster_Danger)
	(L.L.cockpit_light_MotorTemperature) ||
	(L.L.PassengerDanger_Cancel) ! &&
	(L.L.cp_IndicatorLightControl_sw) ! &&
	(L.L.elec_busbar_main) *
	(S.L.Main_Alarm)

'	Cooling Water
	(L.L.engine_temperature) 110 >
	(L.L.cp_IndicatorLightControl_sw) ||
	(L.L.elec_busbar_main) *
	(S.L.cp_light_engine_kuehlwasser)

'	Tank
	(L.L.CheckLights)
	(L.L.engine_tank_content) 50 < ||
	(L.L.cp_IndicatorLightControl_sw) ||
	(L.L.elec_busbar_main) *
	(S.L.cockpit_light_LowDiesel)

'	Batterie
	(L.L.cp_IndicatorLightControl_sw)
	(L.L.elec_ladekontrolle) ||
	(L.L.elec_busbar_main) *
	(S.L.cockpit_light_batterie)

'	Central Lubrication
	(L.L.cockpit_light_zentralschmierung_soll)
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_zentralschmierung)

'	Door Control
	(C.L.cockpit_aftdoorlight_condition_D92)
	{if}
		(L.L.door_2) 0 = 
		(L.L.door_3) 0 = || !
		(L.L.door_4) 0 = || !
		(L.L.door_5) 0 = || !
		(L.L.door_6) 0 = || !
		(L.L.door_7) 0 = || !
		(L.L.door_8) 0 = || !
		(L.L.door_9) 0 = || !
	{else}
		(L.L.door_2) 0.11 > 
		(L.L.door_3) 0.11 > ||
		(L.L.door_4) 0.11 > ||
		(L.L.door_5) 0.11 > ||
		(L.L.door_6) 0.11 > ||
		(L.L.door_7) 0.11 > ||
		(L.L.door_8) 0.11 > ||
		(L.L.door_9) 0.11 > ||
		(L.L.doorTarget_23) ||
		(L.L.doorTarget_45) ||
		(L.L.doorTarget_67) ||
		(L.L.doorTarget_89) ||
	{endif}
	(L.L.door_2) 0 > 
	(L.L.door_3) 0 > || !
	(L.L.door_4) 0 > || !
	(L.L.door_5) 0 > || !
	(L.L.door_6) 0 > || !
	(L.L.door_7) 0 > || !
	(L.L.door_8) 0 > || !
	(L.L.door_9) 0 > || !
	(L.L.elec_busbar_main) &&
	(L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) < &&
	(S.L.cockpit_light_tuerkontrolle)

	(L.L.doorEntriegelung_E_active_01)
	(L.L.doorEntriegelung_E_active_23) ||
	(L.L.doorEntriegelung_E_active_45) ||
	(L.L.doorEntriegelung_E_active_67) ||
	(L.L.doorEntriegelung_E_active_89) ||
	(L.L.elec_busbar_main) *
	(S.L.cockpit_light_tuerentriegelung)

'	Check parking brake
	(L.L.bremse_p_Brzyl_FBA) 650000 <
	(L.L.cp_IndicatorLightControl_sw) ||
	(L.L.elec_busbar_main) *
	(S.L.cockpit_light_feststellbremse)

'	Speed Warning
	(L.L.Velocity) 54 > (L.L.elec_busbar_main) *
	(S.L.cockpit_light_speedwarning)

'	Others lights
	(L.L.cp_retarder_sw_direkt) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_retarder_direkt)

'	(L.L.cp_retarder_sw) (L.L.elec_busbar_main) *
'	(S.L.cockpit_light_retarder)

	(L.L.cp_retarder_sw) 0 = (L.L.elec_busbar_main) *
	(S.L.cockpit_light_retarder)

	(L.L.cp_fahrerlicht) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_fahrerlicht)

	(L.L.cp_TicketTable) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_TicketTable)

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

	(L.L.cp_licht_unterdeck) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_licht_unterdeck)

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

	(L.L.cp_aircon_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_Aircon)
	
	(L.L.cp_spiegelheizung_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_spiegelheizung)

	(L.L.cp_motorkuehlung_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_motorkuehlung)

	(L.L.door_handsteuerung) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_tuer_handsteuerung)

	(L.L.door_handsteuerung_2) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_tuer_handsteuerung_2)

	(L.L.cp_ASR_off) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_ASR_off)

	(L.L.cp_hub_up_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_hub_up)

	(L.L.cp_hub_dn_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_hub_dn)

	(L.L.cp_knick_ovrd_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_knick_ovrd)

	(L.L.bremse_halte) (L.L.elec_busbar_main) *
	(S.L.bremse_halte_light)

	(L.L.DEV_Mode) (L.L.elec_busbar_main) *
	(S.L.DEV_light)

	(L.L.DoorSecu) (L.L.elec_busbar_main) *
	(S.L.DoorSecu_light)

	(L.L.elec_busbar_main)
	(L.L.Velocity) (C.L.Door_Bremse_Halte_MaxKMH) < &&
	(S.L.cockpit_light_MaxKMH)

	(L.L.cp_IndicatorLightControl_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_IndicatorLightControl)

	(L.L.cp_dummy_sw03) (L.L.elec_busbar_main) *
	(S.L.cp_dummy_sw03_light)
{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:tankuhr_frame}
	(L.L.engine_tank_content) (L.L.elec_busbar_main) * s0

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

{macro:engine_thermometer_frame}
	(L.L.engine_temperature) (F.L.cockpit_engine_temperature) (L.L.elec_busbar_main) * s0

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

{macro:Main_Pressurewinkel}
	(L.L.bremse_p_tank01)
	(L.L.bremse_p_tank02)
	(S.L.Main_PressureWinkel)
{end}

{macro:dachluke_pos_rot}
	l0 0.5 <=
	{if}
		0 s1 s2 s3 s4
		(T.L.ev_dachluke_close)
	{else}
	l0 1.5 <=
	{if}
		0.5 s1
		1 s2
		0.80 s3
		0.10 s4
		(T.L.ev_dachluke_open)
	{else}
	l0 2.5 <=
	{if}
		1 s1
		0 s2
		1 s3
		1 s4
		(T.L.ev_dachluke_change)
	{else}
		0.5 s1
		-1 s2
		0.10 s3
		0.80 s4
		(T.L.ev_dachluke_change)
	{endif}
	{endif}
	{endif}
{end}
	

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

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

{macro:klappfenstersound_T}
	l1
	{if}
		(T.L.ev_klappfenster_opn_T)
	{else}
		(T.L.ev_klappfenster_cls_T)
	{endif}	
{end}

{macro:klimator_frame}

'Frontheizgerät:
	(L.L.cp_klimator_sw) (L.L.elec_busbar_main) * s1

'Anlauf oder Auslauf?
	l1 100 * (L.L.cp_klimator_RPM) > 
	{if}
		1.5 s0
	{else}
		0.5 s0
	{endif}

' Berechnung der Luefterbeschleunigung:

'Sollwert:
	l1 100 * 
'Istwert:
	(L.L.cp_klimator_RPM)
'Beschleunigung:
	- s0 * (L.S.Timegap) *
'Addition zum Istwert:
	(L.L.cp_klimator_RPM) + (S.L.cp_klimator_RPM)

'Leitwert generieren:
	(L.L.cp_klimator_sw) 0.5 >
	{if}
		(L.L.elec_busbar_Rinv_summe) (C.L.cp_klimator_Rinv) + (S.L.elec_busbar_Rinv_summe)
	{else}
		(L.L.cp_klimator_sw) -0.5 <
		{if}
			(L.L.elec_busbar_Rinv_summe) (C.L.cp_klimator_Rinv) 0.6 * + (S.L.elec_busbar_Rinv_summe)
		{endif}
	{endif}

'Raumheizgeräte:
	(L.L.engine_n) 399 >
	{if}
		(L.L.cp_heizluefter_sw) (L.L.elec_busbar_main) * s1
	{else}
		0 s1
	{endif}

'Anlauf oder Auslauf?
	l1 100 * (L.L.cp_cabinheater_RPM) > 
	{if}
		6 s0
	{else}
		1.0 s0
	{endif}

' Berechnung der Luefterbeschleunigung:

'Sollwert:
	l1 100 * 
'Istwert:
	(L.L.cp_cabinheater_RPM)
'Beschleunigung:
	- s0 * (L.S.Timegap) *
'Addition zum Istwert:
	(L.L.cp_cabinheater_RPM) + (S.L.cp_cabinheater_RPM)

'Leitwert generieren:
	(L.L.cp_heizluefter_sw) 0.5 >
	{if}
		(L.L.elec_busbar_Rinv_summe) (C.L.cp_cabinheater_Rinv) + (S.L.elec_busbar_Rinv_summe)
	{else}
		(L.L.cp_heizluefter_sw) -0.5 <
		{if}
			(L.L.elec_busbar_Rinv_summe) (C.L.cp_cabinheater_Rinv) 0.6 * + (S.L.elec_busbar_Rinv_summe)
		{endif}
	{endif}
{end}

{macro:schluessel_frame}
	(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: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 / + 10 *
	(S.L.cp_odometer_01)

	(L.L.cp_odometer_01) 10 / trunc 
	(L.L.cp_odometer_01) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_1)

	(L.L.cp_odometer_1) 10 / trunc 
	(L.L.cp_odometer_1) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_10)

	(L.L.cp_odometer_10) 10 / trunc 
	(L.L.cp_odometer_10) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_100)

	(L.L.cp_odometer_100) 10 / trunc 
	(L.L.cp_odometer_100) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_1000)

	(L.L.cp_odometer_1000) 10 / trunc 
	(L.L.cp_odometer_1000) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_10000)

	(L.L.cp_odometer_10000) 10 / trunc 
	(L.L.cp_odometer_10000) 10 / d trunc - (F.L.odometer_10er-uebertrag) +
	(S.L.cp_odometer_100000)

	(L.L.kmcounter_m) 100 / (S.L.cp_odometer_01)
{end}

{macro:Digital_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:Hatch1_frame}
	(L.L.cp_Hatch1_dragged) !
	{if}
		(L.L.cp_Hatch1_pos) (L.S.Timegap) (L.L.cp_Hatch1_speed) * + (S.L.cp_Hatch1_pos)

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

		(L.L.cp_Hatch1_pos) 0 >
		{if}
			(L.L.cp_Hatch1_speed) (L.S.Timegap) (L.L.A_Trans_Y) (C.L.cp_Hatch1_anschlagseite) * (L.L.A_Trans_X) /-/ + 0.3 * (L.L.cp_Hatch1_globalangle) * * + (S.L.cp_Hatch1_speed)
		{endif}

		(L.L.cp_Hatch1_speed) s0 (S.L.cp_Hatch1_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.cp_Hatch1_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.cp_Hatch1_speed)
		{endif}


		(L.L.cp_Hatch1_speed) 0 > (L.L.cp_Hatch1_lastspeed) 0 < &&
		(L.L.cp_Hatch1_speed) 0 < (L.L.cp_Hatch1_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_Hatch1_speed)
		{endif}
	{endif}

	(L.L.cp_Hatch1_pos) 0 > (L.L.cp_Hatch1_open) ! &&
	{if}
		(T.L.ev_Hatch1_auf)
		1 (S.L.cp_Hatch1_open)
	{endif}

	(L.L.cp_Hatch1_pos) 0 = (L.L.cp_Hatch1_open) &&
	{if}
		(T.L.ev_Hatch1_zu)
		0 (S.L.cp_Hatch1_open)
	{endif}

	(L.L.cp_Hatch1_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_Hatch1_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}

{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:pressure_warning_needle_frame}
	(L.L.bremse_p_Tank01) (L.L.bremse_p_Tank02) + 2 / (S.L.cockpit_warndruck) (F.L.cockpit_warndruck) (S.L.cockpit_warndruckwinkel)
{end}

{macro:zentralschmierung_frame}
	(L.L.cp_zentralschmierung_nextkm) (L.L.velocity) 3600 / (L.S.Timegap) * + (S.L.cp_zentralschmierung_nextkm)
	(C.L.cockpit_zentralschmierung_dist) >
	(L.L.cp_zentralschmierung_runtime) (C.L.cockpit_zentralschmierung_maxtime) < &&
	{if}
		1 (S.L.cockpit_light_zentralschmierung_soll)
		(L.L.cp_zentralschmierung_runtime) (L.S.Timegap) + (S.L.cp_zentralschmierung_runtime)
	{else}
		(L.L.cockpit_light_zentralschmierung)
		{if}
			0 (S.L.cp_zentralschmierung_nextkm)
		{endif}
		0 (S.L.cockpit_light_zentralschmierung_soll) (S.L.cp_zentralschmierung_runtime)
	{endif}	
{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}

{macro:Fan_frame}
	(L.L.elec_busbar_main) (C.L.elec_busbar_minV) >
	(L.L.cp_Fan) 1 = &&	
	{if}
		(L.L.Timer_Fan-On) 1 <
		{if}
			(L.L.Timer_Fan-On) (L.S.Timegap) 2 / + (S.L.Timer_Fan-On)
		{else}
			1 (S.L.Timer_Fan-On)
		{endif}
		(L.S.Timegap) (L.L.Timer_Fan-On) * s0
		(L.L.Fan_anim) l0 + (S.L.Fan_anim)
		1 (S.L.Timer_Fan-Off)
	{else}
		0 (S.L.Timer_Fan-On)
		(L.L.Timer_Fan-Off) 0 >
		{if}
			(L.L.Timer_Fan-Off) (L.S.Timegap) 9 / - (S.L.Timer_Fan-Off)
			(L.S.Timegap) (L.L.Timer_Fan-Off) * s0 
			(L.L.Fan_anim) l0 + (S.L.Fan_anim)
		{else}
			0 (S.L.Timer_Fan-Off)
		{endif}

		(L.L.Fan_anim) 200 > 
		(L.L.Timer_Fan-On) (L.L.Timer_Fan-Off) = &&
		{if}
			(L.L.Fan_anim) 200 - (S.L.Fan_anim)
		{endif}
	{endif}

	(L.L.Timer_Fan-On) (L.L.Timer_Fan-Off) + (S.L.Fan_Sound)
{end}

{macro:SidePillows}
	(L.L.SidePillows_loadvar) 1 =
	{if}
		(L.L.vis_SidePillows) 0 =
		{if}
			0 (S.L.cp_SidePillows)
		{endif}
		(L.L.vis_SidePillows) 1 =
		{if}
			1 (S.L.cp_SidePillows)
		{endif}
	{endif}
{end}

{macro:Mirrors}
	(L.L.Mirrors_loadvar) 1 =
	{if}
		(L.L.vis_Mirrors) 0 =
		{if}
			0 (S.L.cp_Mirrors)
		{endif}
		(L.L.vis_Mirrors) 1 =
		{if}
			1 (S.L.cp_Mirrors)
		{endif}
	{endif}
{end}

{macro:Ads}
	(L.L.Ad-Left_loadvar) 1 =
	{if}
		(L.L.vis_Ad-Left) 0 =
		{if}
			0 (S.L.Ad-Left_Poster)
			0 (S.L.Ad-Left_Frame)
		{endif}
		(L.L.vis_Ad-Left) 1 =
		{if}
			0 (S.L.Ad-Left_Poster)
			1 (S.L.Ad-Left_Frame)
		{endif}
		(L.L.vis_Ad-Left) 2 =
		{if}
			1 (S.L.Ad-Left_Poster)
			1 (S.L.Ad-Left_Frame)
		{endif}
	{endif}

	(L.L.Ad-Left_loadvar) 0 =
	{if}
		(L.L.cp_Ad-Left) 0 =
		{if}
			0 (S.L.Ad-Left_Poster)
			0 (S.L.Ad-Left_Frame)
		{else}
			(L.L.cp_Ad-Left) 1 =
			{if}
				0 (S.L.Ad-Left_Poster)
				1 (S.L.Ad-Left_Frame)
			{else}
				(L.L.cp_Ad-Left) 2 =
				{if}
					1 (S.L.Ad-Left_Poster)
					1 (S.L.Ad-Left_Frame)
				{else}
					0 (S.L.Ad-Left_Poster)
					0 (S.L.Ad-Left_Frame)
				{endif}
			{endif}
		{endif}
	{endif}

	(L.L.Ad-Right_loadvar) 1 =
	{if}
		(L.L.vis_Ad-Right) 0 =
		{if}
			0 (S.L.Ad-Right_Poster)
			0 (S.L.Ad-Right_Frame)
		{endif}
		(L.L.vis_Ad-Right) 1 =
		{if}
			0 (S.L.Ad-Right_Poster)
			1 (S.L.Ad-Right_Frame)
		{endif}
		(L.L.vis_Ad-Right) 2 =
		{if}
			1 (S.L.Ad-Right_Poster)
			1 (S.L.Ad-Right_Frame)
		{endif}
	{endif}

	(L.L.Ad-Right_loadvar) 0 =
	{if}
		(L.L.cp_Ad-Right) 0 =
		{if}
			0 (S.L.Ad-Right_Poster)
			0 (S.L.Ad-Right_Frame)
		{else}
			(L.L.cp_Ad-Right) 1 =
			{if}
				0 (S.L.Ad-Right_Poster)
				1 (S.L.Ad-Right_Frame)
			{else}
				(L.L.cp_Ad-Right) 2 =
				{if}
					1 (S.L.Ad-Right_Poster)
					1 (S.L.Ad-Right_Frame)
				{else}
					0 (S.L.Ad-Right_Poster)
					0 (S.L.Ad-Right_Frame)
				{endif}
			{endif}
		{endif}
	{endif}

	(L.L.Ad-Back_loadvar) 1 =
	{if}
		(L.L.vis_Ad-Back) 0 =
		{if}
			0 (S.L.Ad-Back_Poster)
			0 (S.L.Ad-Back_Frame)
		{endif}
		(L.L.vis_Ad-Back) 1 =
		{if}
			0 (S.L.Ad-Back_Poster)
			1 (S.L.Ad-Back_Frame)
		{endif}
		(L.L.vis_Ad-Back) 2 =
		{if}
			1 (S.L.Ad-Back_Poster)
			1 (S.L.Ad-Back_Frame)
		{endif}
	{endif}

	(L.L.Ad-Back_loadvar) 0 =
	{if}
		(L.L.cp_Ad-Back) 0 =
		{if}
			0 (S.L.Ad-Back_Poster)
			0 (S.L.Ad-Back_Frame)
		{else}
			(L.L.cp_Ad-Back) 1 =
			{if}
				0 (S.L.Ad-Back_Poster)
				1 (S.L.Ad-Back_Frame)
			{else}
				(L.L.cp_Ad-Back) 2 =
				{if}
					1 (S.L.Ad-Back_Poster)
					1 (S.L.Ad-Back_Frame)
				{else}
					0 (S.L.Ad-Back_Poster)
					0 (S.L.Ad-Back_Frame)
				{endif}
			{endif}
		{endif}
	{endif}
{end}

{macro:FrontFogLights}
	(L.L.FrontFogLights_loadvar) 1 =
	{if}
		(L.L.vis_FrontFogLights) 0 =
		{if}
			0 (S.L.cp_FrontFogLights)
		{endif}
		(L.L.vis_FrontFogLights) 1 =
		{if}
			1 (S.L.cp_FrontFogLights)
		{endif}
	{endif}
{end}

{macro:display}
	(L.L.display_loadvar) 1 =
	{if}
		(L.L.vis_display) 0 =
		{if}
			1 (S.L.LinesCodeRLB)
			0 (S.L.LinesCodeANX)
			0 (S.L.RollBand_type)
			1 (S.L.RollBand_Com)
			0 (S.L.Voll_matrix)
			0 (S.L.LCD_matrix)
			0 (S.L.LED_matrix)
			0 (S.L.LEDPoly_matrix)
			0 (S.L.LCD-LED_matrix)
		{endif}

		(L.L.vis_display) 1 =
		{if}
			1 (S.L.LinesCodeRLB)
			0 (S.L.LinesCodeANX)
			1 (S.L.RollBand_type)
			1 (S.L.RollBand_Com)
			0 (S.L.Voll_matrix)
			0 (S.L.LCD_matrix)
			0 (S.L.LED_matrix)
			0 (S.L.LEDPoly_matrix)
			0 (S.L.LCD-LED_matrix)
		{endif}
		(L.L.vis_display) 2 =
		{if}
			1 (S.L.LinesCodeRLB)
			0 (S.L.LinesCodeANX)
			2 (S.L.RollBand_type)
			1 (S.L.RollBand_Com)
			0 (S.L.Voll_matrix)
			0 (S.L.LCD_matrix)
			0 (S.L.LED_matrix)
			0 (S.L.LEDPoly_matrix)
			0 (S.L.LCD-LED_matrix)
		{endif}

		(L.L.vis_display) 3 =
		{if}
			1 (S.L.LinesCodeRLB)
			0 (S.L.LinesCodeANX)
			3 (S.L.RollBand_type)
			1 (S.L.RollBand_Com)
			0 (S.L.Voll_matrix)
			0 (S.L.LCD_matrix)
			0 (S.L.LED_matrix)
			0 (S.L.LEDPoly_matrix)
			0 (S.L.LCD-LED_matrix)
		{endif}

		(L.L.vis_display) 4 =
		{if}
			0 (S.L.LinesCodeRLB)
			1 (S.L.LinesCodeANX)
			4 (S.L.RollBand_type)
			0 (S.L.RollBand_Com)
			1 (S.L.Voll_matrix)
			0 (S.L.LCD_matrix)
			0 (S.L.LED_matrix)
			0 (S.L.LEDPoly_matrix)
			0 (S.L.LCD-LED_matrix)
		{endif}

		(L.L.vis_display) 5 =
		{if}
			0 (S.L.LinesCodeRLB)
			1 (S.L.LinesCodeANX)
			4 (S.L.RollBand_type)
			0 (S.L.RollBand_Com)
			0 (S.L.Voll_matrix)
			1 (S.L.LCD_matrix)
			0 (S.L.LED_matrix)
			0 (S.L.LEDPoly_matrix)
			1 (S.L.LCD-LED_matrix)
		{endif}

		(L.L.vis_display) 6 =
		{if}
			0 (S.L.LinesCodeRLB)
			1 (S.L.LinesCodeANX)
			4 (S.L.RollBand_type)
			0 (S.L.RollBand_Com)
			0 (S.L.Voll_matrix)
			0 (S.L.LCD_matrix)
			(C.L.Matrix_LEDMonochrome)
			{if}
				1 (S.L.LED_matrix)
				0 (S.L.LEDPoly_matrix)
			{else}
				0 (S.L.LED_matrix)
				1 (S.L.LEDPoly_matrix)
			{endif}
			1 (S.L.LCD-LED_matrix)
		{endif}
	{endif}

	(L.L.display_loadvar) 0 =
	{if}
		(L.L.cp_display) 0 =
		{if}
			1 (S.L.LinesCodeRLB)
			0 (S.L.LinesCodeANX)
			0 (S.L.RollBand_type)
			1 (S.L.RollBand_Com)
			0 (S.L.Voll_matrix)
			0 (S.L.LCD_matrix)
			0 (S.L.LED_matrix)
			0 (S.L.LEDPoly_matrix)
			0 (S.L.LCD-LED_matrix)
		{else}
			(L.L.cp_display) 1 =
			{if}
				1 (S.L.LinesCodeRLB)
				0 (S.L.LinesCodeANX)
				1 (S.L.RollBand_type)
				1 (S.L.RollBand_Com)
				0 (S.L.Voll_matrix)
				0 (S.L.LCD_matrix)
				0 (S.L.LED_matrix)
				0 (S.L.LEDPoly_matrix)
				0 (S.L.LCD-LED_matrix)
			{else}
				(L.L.cp_display) 2 =
				{if}
					1 (S.L.LinesCodeRLB)
					0 (S.L.LinesCodeANX)
					2 (S.L.RollBand_type)
					1 (S.L.RollBand_Com)
					0 (S.L.Voll_matrix)
					0 (S.L.LCD_matrix)
					0 (S.L.LED_matrix)
					0 (S.L.LEDPoly_matrix)
					0 (S.L.LCD-LED_matrix)
				{else}
					(L.L.cp_display) 3 =
					{if}
						1 (S.L.LinesCodeRLB)
						0 (S.L.LinesCodeANX)
						3 (S.L.RollBand_type)
						1 (S.L.RollBand_Com)
						0 (S.L.Voll_matrix)
						0 (S.L.LCD_matrix)
						0 (S.L.LED_matrix)
						0 (S.L.LEDPoly_matrix)
						0 (S.L.LCD-LED_matrix)
					{else}
						(L.L.cp_display) 4 =
						{if}
							0 (S.L.LinesCodeRLB)
							1 (S.L.LinesCodeANX)
							4 (S.L.RollBand_type)
							0 (S.L.RollBand_Com)
							1 (S.L.Voll_matrix)
							0 (S.L.LCD_matrix)
							0 (S.L.LED_matrix)
							0 (S.L.LEDPoly_matrix)
							0 (S.L.LCD-LED_matrix)
						{else}
							(L.L.cp_display) 5 =
							{if}
								0 (S.L.LinesCodeRLB)
								1 (S.L.LinesCodeANX)
								4 (S.L.RollBand_type)
								0 (S.L.RollBand_Com)
								0 (S.L.Voll_matrix)
								1 (S.L.LCD_matrix)
								0 (S.L.LED_matrix)
								0 (S.L.LEDPoly_matrix)
								1 (S.L.LCD-LED_matrix)
							{else}
								(L.L.cp_display) 6 =
								{if}
									0 (S.L.LinesCodeRLB)
									1 (S.L.LinesCodeANX)
									4 (S.L.RollBand_type)
									0 (S.L.RollBand_Com)
									0 (S.L.Voll_matrix)
									0 (S.L.LCD_matrix)
									(C.L.Matrix_LEDMonochrome)
									{if}
										1 (S.L.LED_matrix)
										0 (S.L.LEDPoly_matrix)
									{else}
										0 (S.L.LED_matrix)
										1 (S.L.LEDPoly_matrix)
									{endif}

									1 (S.L.LCD-LED_matrix)
								{endif}
							{endif}
						{endif}
					{endif}
				{endif}
			{endif}
		{endif}
	{endif}

	(L.L.InteriorDisplay)
	(L.L.RollBand_type) 4 = ||
	(S.L.Ibis)
	(L.L.ticketprinter) ! &&
	{if}
		1 (S.L.Ibis_Panel)
	{else}
		0 (S.L.Ibis_Panel)
	{endif}
{end}

{macro:InteriorDisplay_load}
	(L.L.InteriorDisplay_loadvar) 1 =
	{if}
		(L.L.vis_InteriorDisplay) 0 =
		{if}
			0 (S.L.InteriorDisplay)
		{endif}
		(L.L.vis_InteriorDisplay) 1 =
		{if}
			1 (S.L.InteriorDisplay)
		{endif}
	{endif}

	(L.L.InteriorDisplay_loadvar) 0 =
	{if}
		(L.L.cp_InteriorDisplay) 0 =
		{if}
			0 (S.L.InteriorDisplay)
		{else}
			(L.L.cp_InteriorDisplay) 1 =
			{if}
				1 (S.L.InteriorDisplay)
			{endif}
		{endif}
	{endif}
{end}

{macro:aircon}
	(L.L.aircon_loadvar) 1 =
	{if}
		(L.L.vis_aircon) 0 =
		{if}
			0 (S.L.cp_aircon)
		{endif}
		(L.L.vis_aircon) 1 =
		{if}
			1 (S.L.cp_aircon)
		{endif}
	{endif}
{end}

{macro:AllDoorManual_load}
	(L.L.AllDoorManual_loadvar) 1 =
	{if}
		(L.L.DoorControl) 0 = 
		{if}
			1 (S.L.Automatic)
		{endif}

		(L.L.DoorControl) 1 = 
		{if}
			0 (S.L.Automatic)
		{endif}
	{endif}

	(L.L.AllDoorManual_loadvar) 0 =
	{if}
		(L.L.AllDoorManual) 0 =
		{if}
			1 (S.L.Automatic)
		{else}
			(L.L.AllDoorManual) 1 =
			{if}
				0 (S.L.Automatic)
			{else}
				1 (S.L.Automatic)
			{endif}
		{endif}
	{endif}
{end}

{macro:3rdWiper}
	(L.L.3rdWiper_loadvar) 1 =
	{if}
		(L.L.vis_3rdWiper) 0 =
		{if}
			0 (S.L.cp_3rdWiper)
		{endif}
		(L.L.vis_3rdWiper) 1 =
		{if}
			1 (S.L.cp_3rdWiper)
		{endif}
	{endif}
{end}

{macro:Telma-Bell}
	(L.L.Telma-Bell_loadvar) 1 =
	{if}
		(L.L.vis_Telma-Bell) 0 =
		{if}
			0 (S.L.Telma-Bell)
		{endif}
		(L.L.vis_Telma-Bell) 1 =
		{if}
			1 (S.L.Telma-Bell)
		{endif}
		(L.L.vis_Telma-Bell) 2 =
		{if}
			2 (S.L.Telma-Bell)
		{endif}
	{endif}

	(L.L.Telma-Bell_loadvar) 0 =
	{if}
		(L.L.cp_Telma-Bell) 0 =
		{if}
			0 (S.L.Telma-Bell)
		{else}
			(L.L.cp_Telma-Bell) 1 =
			{if}
				1 (S.L.Telma-Bell)
			{else}
				(L.L.cp_Telma-Bell) 2 =
				{if}
					2 (S.L.Telma-Bell)
				{else}
					0 (S.L.Telma-Bell)
				{endif}
			{endif}
		{endif}
	{endif}
{end}

{macro:AdditionalMeter}
	(L.L.AdditionalMeter_loadvar) 1 =
	{if}
		(L.L.vis_AdditionalMeter) 0 =
		{if}
			0 (S.L.cp_AdditionalMeter)
		{endif}

		(L.L.vis_AdditionalMeter) 1 = 
		{if}
			1 (S.L.cp_AdditionalMeter)
		{endif}

		(L.L.vis_AdditionalMeter) 2 = 
		{if}
			2 (S.L.cp_AdditionalMeter)
		{endif}

		(L.L.Ticketprinter)
		{if}
			0 (S.L.cp_AdditionalMeter)
		{endif}
	{endif}

	(L.L.AdditionalMeter_loadvar) 0 =
	{if}
		(L.L.cp_AdditionalMeter) 0 =
		{if}
			0 (S.L.cp_AdditionalMeter)
		{else}
			(L.L.cp_AdditionalMeter) 1 =
			{if}
				1 (S.L.cp_AdditionalMeter)
			{else}
				(L.L.cp_AdditionalMeter) 2 =
				{if}
					2 (S.L.cp_AdditionalMeter)
				{else}
					0 (S.L.cp_AdditionalMeter)
				{endif}
			{endif}
		{endif}

		(L.L.Ticketprinter)
		{if}
			0 (S.L.cp_AdditionalMeter)
		{endif}
	{endif}
{end}

{macro:Odometer}
	(L.L.Odometer_loadvar) 1 =
	{if}
		(L.L.vis_Odometer) 0 = 
		{if}
			0 (S.L.Odometer)
		{endif}

		(L.L.vis_Odometer) 1 = 
		{if}
			1 (S.L.Odometer)
		{endif}
	{endif}

	(L.L.Odometer_loadvar) 0 =
	{if}
		(L.L.cp_Odometer) 0 =
		{if}
			0 (S.L.Odometer)
		{else}
			(L.L.cp_Odometer) 1 =
			{if}
				1 (S.L.Odometer)
			{else}
				0 (S.L.Odometer)
			{endif}
		{endif}
	{endif}
{end}

{macro:SteeringWheel}
	(L.L.SteeringWheel_loadvar) 1 =
	{if}
		(L.L.vis_SteeringWheel) 0 =
		{if}
			(L.L.cp_lenkrad_visible)
			{if}
				1 (S.L.SteeringWheel)
			{else}
				0 (S.L.SteeringWheel)
			{endif}
		{endif}

		(L.L.vis_SteeringWheel) 1 =
		{if}
			(L.L.cp_lenkrad_visible)
			{if}
				2 (S.L.SteeringWheel)
			{else}
				0 (S.L.SteeringWheel)
			{endif}
		{endif}
	{endif}

	(L.L.SteeringWheel_loadvar) 0 =
	{if}
		(L.L.cp_SteeringWheel) 0 =
		{if}
			(L.L.cp_lenkrad_visible)
			{if}
				1 (S.L.SteeringWheel)
			{else}
				0 (S.L.SteeringWheel)
			{endif}
		{else}
			(L.L.cp_SteeringWheel) 1 =
			{if}
				(L.L.cp_lenkrad_visible)
				{if}
					2 (S.L.SteeringWheel)
				{else}
					0 (S.L.SteeringWheel)
				{endif}
			{else}
				(L.L.cp_lenkrad_visible)
				{if}
					1 (S.L.SteeringWheel)
				{else}
					0 (S.L.SteeringWheel)
				{endif}
			{endif}
		{endif}
	{endif}
{end}

{macro:Hubcaps}
	(L.L.hubcaps_loadvar) 1 =
	{if}
		(L.L.vis_hubcaps) 0 = 
		{if}
			0 (S.L.hubcap)
		{endif}

		(L.L.vis_hubcaps) 1 = 
		{if}
			1 (S.L.hubcap)
		{endif}

		(L.L.vis_hubcaps) 2 = 
		{if}
			2 (S.L.hubcap)
		{endif}
	{endif}

	(L.L.hubcaps_loadvar) 0 =
	{if}
		(L.L.cp_hubcaps) 0 =
		{if}
			0 (S.L.hubcap)
		{else}
			(L.L.cp_hubcaps) 1 =
			{if}
				1 (S.L.hubcap)
			{else}
				(L.L.cp_hubcaps) 2 =
				{if}
					2 (S.L.hubcap)
				{else}
					0 (S.L.hubcap)
				{endif}
			{endif}
		{endif}
	{endif}
{end}

{macro:Ticketprinter}
	(L.L.Ticketprinter_loadvar) 1 =
	{if}
		(L.L.vis_Ticketprinter) 0 =
		{if}
			0 (S.L.Ticketprinter)
			(L.L.elec_busbar_main) 0.1 >=
			{if}
				1 (S.L.Prodata_Displays)
				0 (S.L.PFE_Displays)
			{endif}
		{endif}
		(L.L.vis_Ticketprinter) 1 =
		{if}
			1 (S.L.Ticketprinter)
			(L.L.elec_busbar_main) 0.1 >=
			{if}
				0 (S.L.Prodata_Displays)
				1 (S.L.PFE_Displays)
			{endif}
		{endif}
	{endif}

	(L.L.ticketprinter_loadvar) 0 =
	{if}
		(L.L.Ticketprinter) 0 =
		(L.L.elec_busbar_main) 0.1 >= &&
		{if}
			1 (S.L.Prodata_Displays)
			0 (S.L.PFE_Displays)
		{else}
			(L.L.Ticketprinter) 1 =
			(L.L.elec_busbar_main) 0.1 >= &&
			{if}
				0 (S.L.Prodata_Displays)
				1 (S.L.PFE_Displays)
			{endif}
		{endif}
	{endif}
{end}

{macro:ServicesPlates}
	(L.L.ServicesPlates_loadvar) 1 =
	{if}
		(L.L.vis_ServicePlate) 0 =
		{if}
			0 (S.L.Formation)
			0 (S.L.SchoolPlate)
			0 (S.L.Work)
		{endif}

		(L.L.vis_ServicePlate) 1 =
		{if}
			1 (S.L.Formation)
			0 (S.L.SchoolPlate)
			0 (S.L.Work)
		{endif}
		(L.L.vis_ServicePlate) 2 =
		{if}
			0 (S.L.Formation)
			1 (S.L.SchoolPlate)
			0 (S.L.Work)
		{endif}

		(L.L.vis_ServicePlate) 3 =
		{if}
			0 (S.L.Formation)
			0 (S.L.SchoolPlate)
			1 (S.L.Work)
		{endif}
	{endif}

	(L.L.ServicesPlates_loadvar) 0 =
	{if}
		(L.L.ServicePlate_selected) 0 =
		{if}
			0 (S.L.Formation)
			0 (S.L.SchoolPlate)
			0 (S.L.Work)
		{else}
			(L.L.ServicePlate_selected) 1 =
			{if}
				1 (S.L.Formation)
				0 (S.L.SchoolPlate)
				0 (S.L.Work)
			{else}
				(L.L.ServicePlate_selected) 2 =
				{if}
					0 (S.L.Formation)
					1 (S.L.SchoolPlate)
					0 (S.L.Work)
				{else}
					(L.L.ServicePlate_selected) 3 =
					{if}
						0 (S.L.Formation)
						0 (S.L.SchoolPlate)
						1 (S.L.Work)
					{endif}
				{endif}
			{endif}
		{endif}
	{endif}
{end}

{macro:WindPlates}
	(L.L.WindPlates_loadvar) 1 =
	{if}
		(L.L.vis_WindshieldPlate) 0 =
		{if}
			0 (S.L.WindshieldPlate)
			0 (S.L.WindshieldPlateHolder)
		{endif}

		(L.L.vis_WindshieldPlate) 1 =
		{if}
			1 (S.L.WindshieldPlate)
			1 (S.L.WindshieldPlateHolder)
		{endif}

		(L.L.vis_WindshieldPlate) 2 =
		{if}
			2 (S.L.WindshieldPlate)
			1 (S.L.WindshieldPlateHolder)
		{endif}
	{endif}

	(L.L.WindPlates_loadvar) 0 =
	{if}
		(L.L.WindshieldPlate_selected) 0 =
		{if}
			0 (S.L.WindshieldPlate)
			0 (S.L.WindshieldPlateHolder)
		{else}
			(L.L.WindshieldPlate_selected) 1 =
			{if}
				1 (S.L.WindshieldPlate)
				1 (S.L.WindshieldPlateHolder)
			{else}
				(L.L.WindshieldPlate_selected) 2 =
				{if}
					2 (S.L.WindshieldPlate)
					1 (S.L.WindshieldPlateHolder)
				{endif}
			{endif}
		{endif}
	{endif}
{end}

{macro:Engine_PWR_mode}
	(L.L.Engine_PWR_mode_loadvar) 1 =
	{if}
		(L.L.vis_Motor_PWR_mode) 0 =
		{if}
			0 (S.L.cp_Engine_PWR_mode)
		{endif}
		(L.L.vis_Motor_PWR_mode) 1 =
		{if}
			1 (S.L.cp_Engine_PWR_mode)
		{endif}
	{endif}

	(L.L.Engine_PWR_mode_loadvar) 0 =
	{if}
		(L.L.cp_Engine_PWR_mode) 0 =
		{if}
			0 (S.L.vis_Motor_PWR_mode)
		{else}
			(L.L.cp_Engine_PWR_mode) 1 =
			{if}
				1 (S.L.vis_Motor_PWR_mode)
			{else}
				0 (S.L.vis_Motor_PWR_mode)
			{endif}
		{endif}
	{endif}
{end}