'##############
'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	lü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
'- Vitaly L.		14.01.2016	Âûğåçàíî ëèøíåå,äîáàâëåíû ñêğèïòû âñÿêèõ ñïğèíòåğîâñêèõ õåğíåé.
'- Vitaly L.		15.12.2016	Äîáàâëåíà ïğåäïóñêîâàÿ ïğîâåğêà êîíòğîëüíûõ ëàìï.
'- Kakp		        26.04.2026	Imitation of the baggage loading and unloading system  
.
'------------------------------------------------------------------------------------------

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

{trigger:cp_batterietrennschalter_toggle}
	(L.L.elec_busbar_main_sw) ! (S.L.elec_busbar_main_sw) 
	(L.L.cp_batterietrennschalter_antirepeat) !
	{if}
		(L.L.elec_busbar_main_sw)
		{if}
			(T.L.ev_schluessel_steck)
			1 (S.L.bremse_ABS_selftest) (S.L.cp_taster_batterietrennschalter) (S.L.cp_proverka_start)
		{else}
			(T.L.ev_schluessel_steck)
			0 (S.L.cp_schluessel_trans) (S.L.cp_proverka_time)
		{endif}
		1 (S.L.cp_batterietrennschalter_antirepeat)
	{endif}		
{end}

{trigger:cp_batterietrennschalter_toggle_off}
	0 (S.L.cp_batterietrennschalter_antirepeat) (S.L.cp_taster_batterietrennschalter)
{end}

{trigger:horn}
	
	(L.L.cockpit_hupe) ! (L.L.elec_busbar_main) &&
	{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) &&
	{if}
		(T.L.ev_hupe_aus)
	{endif}
	0 (S.L.cockpit_hupe)	
	
{end}

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


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

{trigger:cp_retarder_toggle}
	(C.L.cockpit_has_retarderswitch)
	{if}
		(L.L.cp_retarder_sw) ! (S.L.cp_retarder_sw) s1
		(M.L.kippschaltersound)
	{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_sw) !
	(L.L.cp_fahrerlicht_1_sw) ! &&
	{if}
		1 (S.L.cp_fahrerlicht_sw)
		(T.L.ev_kippschalter_ein)
	{else}
		(L.L.cp_fahrerlicht_sw)
		(L.L.cp_fahrerlicht_1_sw) ! &&
		{if}
			1 (S.L.cp_fahrerlicht_1_sw) (S.L.cp_fahrerlicht_sw)
			(T.L.ev_kippschalter_ein)
		{else}
			(L.L.cp_fahrerlicht_1_sw)
			{if}
				0 (S.L.cp_fahrerlicht_sw) (S.L.cp_fahrerlicht_1_sw)
				(T.L.ev_kippschalter_aus)
			{endif}
		{endif}
	{endif}
{end}

{trigger:cp_licht_untenrechts_toggle}
	(L.L.cp_licht_untenrechts_sw) 
	{if}
		0 (S.L.cp_licht_oberdeck_sw) (S.L.cp_licht_unterdeck_sw) (S.L.cp_licht_untenrechts_sw) s1
	{else}
		1 (S.L.cp_licht_oberdeck_sw) (S.L.cp_licht_unterdeck_sw) (S.L.cp_licht_untenrechts_sw) s1
	{endif}		
	(M.L.kippschaltersound)
{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_batterietrennschalter}
	1 (S.L.cp_taster_batterietrennschalter)
	{if}
		1 (S.L.elec_busbar_main_sw)
	{endif}

{end}

{trigger:kw_batterietrennschalter_off}
	0 (S.L.cp_taster_batterietrennschalter)
{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_cps_mov_drag}

	(L.S.mouse_x) abs (L.S.mouse_y) abs >
	{if}
        (L.S.mouse_x) -60 / (L.L.cp_cps_rot) + 0 max 1 min (S.L.cp_cps_rot) s0
{endif}
	(L.S.mouse_y) -20 / (L.L.cp_cps_trans) + 0 max 1 min (S.L.cp_cps_trans) s1
		l1 0.2 <
		{if}
			0 (S.L.cp_cps_trans_mode) 
		{else} 
			l1 0.8 <
			{if}
				1 (S.L.cp_cps_trans_mode) 
			{else}
				2 (S.L.cp_cps_trans_mode)
			{endif}
		{endif}
	{endif}
{end}

{trigger:cp_timer_back}
	(L.L.cp_timer_mode) 1 = 
	{if}
		0 (S.L.cp_timer_mode)
	{endif}
{end}

{trigger:cp_timer_stop}
	(L.L.cp_timer_stop_position) !
	(L.L.cp_timer_mode) 0 = &&
	{if}
		1 (S.L.cp_timer_stop_position)
	{else}
		(L.S.Time) (S.L.cp_timer_minus)
		0 (S.L.cp_timer_stop_position)
	{endif}
{end}

{trigger:cp_timer_stop_off}
	0 (S.L.cp_timer_delay)
{end}

{trigger:cp_timer_next}
	(L.L.cp_timer_mode) ! 
	{if}
		1 (S.L.cp_timer_mode)
	{endif}
{end}

{trigger:cp_cps_mov_off}
	(L.L.cp_cps_trans_mode) 2 / (S.L.cp_cps_trans)

{end}

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


{trigger:cp_kn_door_light}
	(L.L.doorAcc_0) 0.1 >
	{if}
		0 (S.L.cp_kn_door_light) s1
	{else}
		1 (S.L.cp_kn_door_light) s1
	{endif}		
	(M.L.kippschaltersound)
{end}

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

{trigger:cp_listok}
	(L.L.cp_listok) ! (S.L.cp_listok) s1
	(T.L.ev_listok)
{end}

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

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

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

{trigger:cp_marshryt_pered}
	(L.L.cp_marshryt_pered) 2 = 
  {if}
    0 (S.L.cp_marshryt_pered)
  {else}
    (L.L.cp_marshryt_pered) 1 + (S.L.cp_marshryt_pered)
  {endif}
  (M.L.kippschaltersound)

{end}


{trigger:cp_marshryt_bok}
	(L.L.cp_marshryt_bok) 2 = 
  {if}
    0 (S.L.cp_marshryt_bok)
  {else}
    (L.L.cp_marshryt_bok) 1 + (S.L.cp_marshryt_bok)
  {endif}
  (M.L.kippschaltersound)
{end}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

{trigger:cp_dummy_sw05_toggle}
	(L.L.cp_dummy_sw05) ! (S.L.cp_dummy_sw05) s1
	(M.L.kippschaltersound)
{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_kozir_L_drag}
     
    (L.S.mouse_y) 200 / (L.L.cp_kozir_L_pos) + 0 max 1 min (S.L.cp_kozir_L_pos) s0

   
    (L.L.cp_kozir_L_pos) 0 > (L.L.cp_kozir_L_opn) ! &&
    {if}
       	(T.L.ev_kozir_opn)
	1 (S.L.cp_kozir_L_opn)
    {endif}
   
    (L.L.cp_kozir_L_pos) 0 = (L.L.cp_kozir_L_opn) &&
    {if}
       		(T.L.ev_kozir_cls)
		0 (S.L.cp_kozir_L_opn)
    {endif}

{end}


{trigger:cp_kozir_P_drag}
     
    (L.S.mouse_y) 200 / (L.L.cp_kozir_P_pos) + 0 max 1 min (S.L.cp_kozir_P_pos) s0

   
    (L.L.cp_kozir_P_pos) 0 > (L.L.cp_kozir_P_opn) ! &&
    {if}
       	(T.L.ev_kozir_opn)
	1 (S.L.cp_kozir_P_opn)
    {endif}
   
    (L.L.cp_kozir_P_pos) 0 = (L.L.cp_kozir_P_opn) &&
    {if}
       		(T.L.ev_kozir_cls)
		0 (S.L.cp_kozir_P_opn)
    {endif}

{end}

{trigger:cp_bardachok_drag}
     
    (L.S.mouse_y) 200 / (L.L.cp_bardachok_pos) + 0 max 1 min (S.L.cp_bardachok_pos) s0
   
    (L.L.cp_bardachok_pos) 0 > (L.L.cp_bard_opn) ! &&
    {if}
       	(T.L.ev_bard_opn)
	1 (S.L.cp_bard_opn)
    {endif}
   
    (L.L.cp_bardachok_pos) 0 = (L.L.cp_bard_opn) &&
    {if}
       		(T.L.ev_bard_cls)
		0 (S.L.cp_bard_opn)
    {endif}

{end} 


{trigger:cp_pepelnitsa_drag}
     
    (L.S.mouse_y) 200 / (L.L.cp_pepelnitsa_pos) + 0 max 1 min (S.L.cp_pepelnitsa_pos) s0

    (L.L.cp_pepelnitsa_pos) 0 > (L.L.cp_pepelnitsa_opn) ! &&
    {if}
       	(T.L.ev_pepel_sound_opn)
	1 (S.L.cp_pepelnitsa_opn)
    {endif}
   
    (L.L.cp_pepelnitsa_pos) 0 = (L.L.cp_pepelnitsa_opn) &&
    {if}
       		(T.L.ev_pepel_sound_cls)
		0 (S.L.cp_pepelnitsa_opn)
    {endif}

{end}
  
 
 

{trigger:cp_kn_obduv}
	(L.L.cp_kn_obduv) ! (S.L.cp_kn_obduv) 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:luk_1}
	(L.L.cp_luk_1) !
	(L.L.cp_luk_1_rot) ! &&
	(L.L.cp_luk_1_trans) ! &&
	{if}
		1 (S.L.cp_luk_1)
		(T.L.ev_luk_opn)
	{else}
		(L.L.cp_luk_1)
		{if}
			1 (S.L.cp_luk_1_rot)
			0 (S.L.cp_luk_1)
			(T.L.ev_luk_opn)
		{else}
			(L.L.cp_luk_1_rot)
			{if}
				1 (S.L.cp_luk_1_trans)
				0 (S.L.cp_luk_1) (S.L.cp_luk_1_rot)
				(T.L.ev_luk_opn)
			{else}
				0 (S.L.cp_luk_1_trans) (S.L.cp_luk_1) (S.L.cp_luk_1_rot)
				(T.L.ev_luk_cls)
			{endif}
		{endif}
	{endif}
{end}

{trigger:luk_2}
	(L.L.cp_luk_2) !
	(L.L.cp_luk_2_rot) ! &&
	(L.L.cp_luk_2_trans) ! &&
	{if}
		1 (S.L.cp_luk_2)
		(T.L.ev_luk_opn)
	{else}
		(L.L.cp_luk_2)
		{if}
			1 (S.L.cp_luk_2_rot)
			0 (S.L.cp_luk_2)
			(T.L.ev_luk_opn)
		{else}
			(L.L.cp_luk_2_rot)
			{if}
				1 (S.L.cp_luk_2_trans)
				0 (S.L.cp_luk_2) (S.L.cp_luk_2_rot)
				(T.L.ev_luk_opn)
			{else}
				0 (S.L.cp_luk_2_trans) (S.L.cp_luk_2) (S.L.cp_luk_2_rot)
				(T.L.ev_luk_cls)
			{endif}
		{endif}
	{endif}
{end}

{trigger:cp_fort_L1_opn_drag}

	(L.L.cp_fort_L1_pos) (S.L.cp_fort_L1_lastpos)

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

	(L.L.cp_fort_L1_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_fort_L1_endanschlag)
	{endif}
	(L.L.cp_fort_L1_pos) (L.L.cp_fort_L1_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}


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

{trigger:cp_fort_R1_opn_drag}

	(L.L.cp_fort_R1_pos) (S.L.cp_fort_R1_lastpos)

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

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


	(L.L.cp_fort_R1_pos) (L.L.cp_fort_R1_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}


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

{trigger:cp_fort_R2_opn_drag}

	(L.L.cp_fort_R2_pos) (S.L.cp_fort_R2_lastpos)

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

	(L.L.cp_fort_R2_pos) s0 0 > l0 1 < &&
	{if}
		0 (S.L.cp_fort_R2_endanschlag)
	{endif}
	(L.L.cp_fort_R2_pos) (L.L.cp_fort_R2_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

{trigger:cp_fort_R2_opn_off}
	0 (S.L.cp_fahrerfenster_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_fortochka_pass_anim_1_opn_drag}

	(L.L.cp_fortochka_pass_anim_1_pos) (S.L.cp_fortochka_pass_anim_1_lastpos)

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

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


	(L.L.cp_fortochka_pass_anim_1_pos) (L.L.cp_fortochka_pass_anim_1_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}


{trigger:cp_fortochka_pass_anim_1_opn_off}
	0 (S.L.cp_fortochka_pass_anim_1_speed)
{end}

{trigger:cp_fortochka_pass_anim_2_opn_drag}

	(L.L.cp_fortochka_pass_anim_2_pos) (S.L.cp_fortochka_pass_anim_2_lastpos)

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

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


	(L.L.cp_fortochka_pass_anim_2_pos) (L.L.cp_fortochka_pass_anim_2_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

{trigger:cp_fortochka_pass_anim_2_opn_off}
	0 (S.L.cp_fortochka_pass_anim_2_speed)
{end}

{trigger:cp_fortochka_pass_anim_3_opn_drag}

	(L.L.cp_fortochka_pass_anim_3_pos) (S.L.cp_fortochka_pass_anim_3_lastpos)

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

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


	(L.L.cp_fortochka_pass_anim_3_pos) (L.L.cp_fortochka_pass_anim_3_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

{trigger:cp_fortochka_pass_anim_3_opn_off}
	0 (S.L.cp_fortochka_pass_anim_3_speed)
{end}

{trigger:cp_fortochka_pass_anim_4_opn_drag}

	(L.L.cp_fortochka_pass_anim_4_pos) (S.L.cp_fortochka_pass_anim_4_lastpos)

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

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


	(L.L.cp_fortochka_pass_anim_4_pos) (L.L.cp_fortochka_pass_anim_4_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

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

{trigger:cp_tabla_toggle}
	(L.L.cp_tabla_visible) ! (S.L.cp_tabla_visible)
{end}

{trigger:cp_tabla1_toggle}
	(L.L.cp_tabla1_visible) ! (S.L.cp_tabla1_visible)
{end}

{trigger:cp_krishka}
	(L.L.cp_krishka) ! (S.L.cp_krishka) s1
	 	 
	{if}
		1 (S.L.cp_krishka)
		(T.L.ev_krishka_opn)
		
	{else}
		0 (S.L.cp_krishka)
		(T.L.ev_krishka_cls)
	{endif}


{end}
 

{trigger:cp_shtor_1}
	(L.L.cp_shtor_1) ! (S.L.cp_shtor_1) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_2}
	(L.L.cp_shtor_2) ! (S.L.cp_shtor_2) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_3}
	(L.L.cp_shtor_3) ! (S.L.cp_shtor_3) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_4}
	(L.L.cp_shtor_4) ! (S.L.cp_shtor_4) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_5}
	(L.L.cp_shtor_5) ! (S.L.cp_shtor_5) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_6}
	(L.L.cp_shtor_6) ! (S.L.cp_shtor_6) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_7}
	(L.L.cp_shtor_7) ! (S.L.cp_shtor_7) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_8}
	(L.L.cp_shtor_8) ! (S.L.cp_shtor_8) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_9}
	(L.L.cp_shtor_9) ! (S.L.cp_shtor_9) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_10}
	(L.L.cp_shtor_10) ! (S.L.cp_shtor_10) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_11}
	(L.L.cp_shtor_11) ! (S.L.cp_shtor_11) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_12}
	(L.L.cp_shtor_12) ! (S.L.cp_shtor_12) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_13}
	(L.L.cp_shtor_13) ! (S.L.cp_shtor_13) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_14}
	(L.L.cp_shtor_14) ! (S.L.cp_shtor_14) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_15}
	(L.L.cp_shtor_15) ! (S.L.cp_shtor_15) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_16}
	(L.L.cp_shtor_16) ! (S.L.cp_shtor_16) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_17}
	(L.L.cp_shtor_17) ! (S.L.cp_shtor_17) s1
	(M.L.shtora_sound)
{end}

{trigger:cp_shtor_18}
	(L.L.cp_shtor_18) ! (S.L.cp_shtor_18) s1
	(M.L.shtora_sound)
{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_Fahrertuer_1_drag}

	1 (S.L.cp_fahrertuer_1_dragged)
	(L.L.cp_fahrertuer_1_pos) (S.L.cp_fahrertuer_1_lastpos)

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

	(L.L.cp_fahrertuer_1_pos) (L.L.cp_fahrertuer_1_lastpos) - (L.S.Timegap) / (S.L.cp_fahrertuer_1_speed)
{end}

{trigger:cp_Fahrertuer_1_off}
	0 (S.L.cp_fahrertuer_1_dragged)
{end}

{trigger:cp_Fahrertuer_2_drag}

	1 (S.L.cp_fahrertuer_2_dragged)
	(L.L.cp_fahrertuer_2_pos) (S.L.cp_fahrertuer_2_lastpos)

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

	(L.L.cp_fahrertuer_2_pos) (L.L.cp_fahrertuer_2_lastpos) - (L.S.Timegap) / (S.L.cp_fahrertuer_2_speed)
{end}

{trigger:cp_Fahrertuer_2_off}
	0 (S.L.cp_fahrertuer_2_dragged)
{end}

{trigger:cp_Fahrertuer_3_drag}

	1 (S.L.cp_fahrertuer_3_dragged)
	(L.L.cp_fahrertuer_3_pos) (S.L.cp_fahrertuer_3_lastpos)

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

	(L.L.cp_fahrertuer_3_pos) (L.L.cp_fahrertuer_3_lastpos) - (L.S.Timegap) / (S.L.cp_fahrertuer_3_speed)
{end}

{trigger:cp_Fahrertuer_3_off}
	0 (S.L.cp_fahrertuer_3_dragged)
{end}

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

{trigger:KR_play}
	(L.L.cockpit_KR_play) ! (S.L.cockpit_KR_play) s1
	(M.L.kippschaltersound)
{end}

{trigger:taster_nebelschluss}

	(L.L.cp_taster_nebelschluss_target) ! (S.L.cp_taster_nebelschluss_target) s1
	(M.L.kippschaltersound)	
	1 (S.L.cp_taster_nebelschluss)		
{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}

{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_drag}
	(L.S.mouse_x) -70 / (L.L.cockpit_heizregler_defrost) + 0 max 1 min (S.L.cockpit_heizregler_defrost)
{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_temp_drag}
	(L.S.mouse_y) -100 / (L.L.cp_heizregler_temp) + (S.L.cp_heizregler_temp) s0
	l0 0 <
	{if}
		0 (S.L.cp_heizregler_temp)
	{endif}
	l0 1 >
	{if}
		1 (S.L.cp_heizregler_temp)
	{endif}
{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_drag}
	(L.S.mouse_y) -150 / (L.L.cockpit_heizregler_umluft) + 0 max 1 min (S.L.cockpit_heizregler_umluft) s0

'	Stufen:
'	0: Umluftheizung
'	1: Direktbelüftung
'	2: Frischluftheizung

	l0 0.2 <
	{if}
		0 (S.L.cockpit_heizregler_ventilation_mode)
	{else}
		l0 0.8 <
		{if}
			1 (S.L.cockpit_heizregler_ventilation_mode)
		{else}
			2 (S.L.cockpit_heizregler_ventilation_mode)
		{endif}
	{endif}

{end}

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

{trigger:knp_odometr_change}
	(L.L.cockpit_odometr_change) ! (S.L.cockpit_odometr_change) s1
	(M.L.kippschaltersound)
{end}

{trigger:knp_odometr_sbros}
		(L.L.kmcounter_km) (S.L.odometer_kmlast)
		(L.L.kmcounter_m) (S.L.odometer_mlast)
		0 (S.L.odometr_sutki)
		0 (S.L.odometr_sutki_metr)
	{endif}
	1 (S.L.cockpit_odometr_sbros)
	(M.L.kippschaltersound)
{end}

{trigger:knp_odometr_sbros_off}
	0 (S.L.cockpit_odometr_sbros)
{end}

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

{macro:cockpit_init}
	0 (S.L.cockpit_hupe_volume) (S.L.cockpit_gangR_volume) (S.L.door_handsteuerung) (S.L.cp_tabla_visible) (S.L.cp_tabla1_visible) (S.L.cp_timer_delay)
	1 (S.L.cp_retarder_sw) (S.L.cp_lenkrad_visible) (S.L.cp_taster_warnblinker) (S.L.cockpit_wischer_drehschalter_mode) 

	0.6 (S.L.cp_taster_warnblinker) (S.L.cp_taster_standheizung)

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

	0.333 (S.L.cockpit_wischer_drehschalter)

	(L.S.Time) (S.L.cp_timer_minus)
{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_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.gangR_frame)
	(M.L.blinkerhebel_frame)
	(M.L.wischerhebel_frame)
	(M.L.wischer_drehschalter_frame)
	(M.L.oeldruck_frame)
	(M.L.fordsz_frame)
	(M.L.tankuhr_frame)
	(M.L.cockpitlights_frame)
	(M.L.klimator_frame)
	(M.L.fahrertuer_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.cps_frame)
	(M.L.Odometr_display)
	(M.L.timer_frame)
	(M.L.luk_frame)
	(M.L.proverka_frame)
	(M.L.kachanie_frame)
	(M.L.windows_frame)
{end}

{macro:tacho_frame}
	(L.L.Velocity) (F.L.cockpit_tacholinie) (S.L.cockpit_tachowinkel)
{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:gangR_frame}
	(L.L.elec_busbar_main)
	{if}
		(L.L.antrieb_getr_gang) -1 =
		{if}
			(L.L.cockpit_gangR_volume) 1 <
			{if}
				(L.L.cockpit_gangR_volume) (L.S.Timegap) 10 * + (S.L.cockpit_gangR_volume)
			{else}
				1 (S.L.cockpit_gangR_volume)
			{endif}
		{else}
			(L.L.cockpit_gangR_volume) 0 >
			{if}
				(L.L.cockpit_gangR_volume) (L.S.Timegap) 10 * - (S.L.cockpit_gangR_volume)
			{else}
				0 (S.L.cockpit_gangR_volume)
			{endif}
		{endif}
	{else}
		(L.L.cockpit_gangR_volume) 0 >
		{if}
			(L.L.cockpit_gangR_volume) (L.S.Timegap) 10 * - (S.L.cockpit_gangR_volume)
		{else}
			0 (S.L.cockpit_gangR_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_cps_trans) 0.8 >
		{if}
			-1 (S.L.cockpit_fernlichthebel)
		{endif}
	{else}
		0 (S.L.cockpit_fernlichthebel)
	{endif}
{end}

{macro:proverka_frame}
(L.L.cp_proverka_start) 1 =
{if}
(L.L.cp_proverka_time) (L.S.Timegap) +
(S.L.cp_proverka_time)
1 (S.L.cp_proverka_start) (S.L.cp_proverka_full) 
{endif}
	(L.L.cp_taster_anlasser) 1 = ||
	{if}
		(L.L.cp_proverka_time) 3 >
		{if}
		0 (S.L.cp_proverka_start)
		{endif}
	(L.L.cp_proverka_time) 2 >
	{if}
	0 (S.L.cp_proverka_full)
	{endif}
{endif}
	(L.L.cp_proverka_start) (L.L.elec_busbar_main) &&
	(S.L.cp_proverka)
	(L.L.cp_proverka_full) (L.L.elec_busbar_main) &&
	(S.L.cp_proverka_all)
{end}

{macro:cps_frame}

	(L.L.cp_cps_trans_lastmode) (L.L.cp_cps_trans_mode) = !
	{if}
		(T.L.ev_schluessel_steck)
	{endif}
	(L.L.cp_cps_trans_mode) (S.L.cp_cps_trans_lastmode)
{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.cp_proverka) ||
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_masterfailure)

	(L.L.elec_busbar_main) 1 =	
	{if}
		(L.L.engine_tank_content) 30 <
		(L.L.cp_proverka) ||
		{if}
			1 (S.L.light_toplivo)
		{else}
			0 (S.L.light_toplivo)
		{endif}
	{else}
		0 s0
		0 (S.L.light_toplivo)
	{endif}	
		(L.L.engine_temperature) 98 >
		(L.L.cp_proverka) 1 = ||
		(L.L.elec_busbar_main) &&
		{if}
			1 (S.L.light_voda)
		{else}
			0 (S.L.light_voda)
		{endif}
		(L.L.engine_temperature) (F.L.cockpit_engine_temperature) s0
	{else}
		0 s0
		0 (S.L.light_voda)
	{endif}

	(L.L.lights_beleuchtung_untenrechts) 1 =
{if}
	1 (S.L.lights_beleuchtung_oberdeck) (S.L.lights_beleuchtung_unterdeck) (S.L.lights_beleuchtung_untenrechts)
{endif}

'	Batterie
	(L.L.elec_ladekontrolle) (L.L.cp_proverka) ||
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_batterie)

'	Türkontrolle
	(C.L.cockpit_aftdoorlight_condition_D92)
	{if}
		(L.L.door_1) 0 = && !
	{else}
		(L.L.door_1) 0.11 > ||
	{endif}
	(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.cp_proverka) ||
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_feststellbremse)

	(L.L.lights_blinkgeber) (L.L.cp_proverka) ||
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_blinker)

	(L.L.lights_fern) (L.L.cp_proverka) ||
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_fern)

	(L.L.bremse_ABS_eingriff) (L.L.cp_proverka_all) ||
	(L.L.elec_busbar_main) &&
	(S.L.cockpit_light_ABS)

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

	(L.L.cp_kn_obduv) 0.2 > (L.L.elec_busbar_main) &&
	(S.L.obduv)

'	Kippschalter-Beleuchtung
	(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_fahrerlicht_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_fahrerlicht)

	(L.L.cp_wischer_schnell_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_schnell)

	(L.L.cp_wischer_einaus_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_einaus)

	(L.L.cp_wischer_intervall_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_intervall)
	
	(L.L.cp_wischer_wascher_sw) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_wischer_wascher)

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

	(L.L.cp_licht_unterdeck_sw) (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)

	(L.L.cp_heizluefter_sw) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_heizluefter)
	
	(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.cp_ASR_off) (L.L.elec_busbar_main) *
	(S.L.cockpit_light_ASR_off)

	(L.L.cp_player_on) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_player)

	(L.L.cockpit_gangR) (L.L.elec_busbar_main) &&
	(S.L.cockpit_light_gangR)

	(L.L.cp_webasto) (L.L.elec_busbar_main) &&
	(S.L.cp_webasto_sound)

'	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)

'--------------------------------- radio

	(L.L.cockpit_KR_play) (L.L.cockpit_light_player) &&
	(S.L.Snd_Radio)
{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:shtora_sound}
	l1
	{if}
		(T.L.ev_shtora)
	{else}
		(T.L.ev_shtora)
	{endif}	
{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:fordsz_frame}
	(L.L.engine_n) (F.L.cockpit_fordsz) s0

	(L.L.elec_busbar_main) !
	{if}
		0 s0
	{endif}

	(L.L.cockpit_fordsz) s1
	5 s2
	5 s3
	(M.L.traegheit)	
	l1 (S.L.cockpit_fordsz)
{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:klimator_frame}

'Frontheizgerät:
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_klimator_sw) s1
	{else}
		0 s1
	{endif}

'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)


'Raumheizgeräte:
	(L.L.elec_busbar_main)
	{if}
		(L.L.cp_heizluefter_sw) 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)
{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:Odometr_display}
	(L.L.elec_busbar_main) 1 =
	{if}
'		Âûâîä îáùåãî ïğîáåãà
		(L.L.kmcounter_km) trunc "06" $IntToStrEnh (S.$.odometr_disp1)
		
'		Ğàñ÷åò ñóòî÷íîãî ïğîáåãà â êì
		(L.L.kmcounter_km) (L.L.odometer_kmlast) - (S.L.odometr_sutki)

'		Ğàñ÷åò ñóòî÷íîãî ïğîáåãà â ìåòğàõ
		(L.L.kmcounter_m) (L.L.odometer_mlast) - 100 / (S.L.odometr_sutki_metr)
		
'		Âûâîä ñóòî÷íîãî ïğîáåãà
		(L.L.odometr_sutki) trunc "04" $IntToStrEnh 
		"." $+
		(L.L.odometr_sutki_metr) trunc "01" $IntToStrEnh $+
		(S.$.odometr_disp2)

'		Åñëè ñóòî÷íûé ïğîáåã áóäåò áîëüøå 9999 êì, òî îí àâòîìàòè÷åñêè ñáğîñèòñÿ (çàùèòà îò äóğàêà)		
		(L.L.odometr_sutki) 9999 >=
		{if}
			(L.L.kmcounter_km) (S.L.odometer_kmlast)
			(L.L.kmcounter_m) (S.L.odometer_mlast)
			0 (S.L.odometr_sutki) (S.L.odometr_sutki_metr)
		{endif}
		
	{else}
		" " $ (S.$.odometr_disp1)
		" " $ (S.$.odometr_disp2)
	{endif}
{end}

{macro:timer_frame}
	(L.L.cp_timer_mode) 1 =
	{if}
		(L.S.Time) 3600 / trunc " 2" s0
		(L.S.Time) 60 / l0 60 * - s1
		(L.S.Time) 60 % s2
	{else}
		(L.L.cp_timer_mode) 0 =
		{if}
			(L.S.Time) (L.L.cp_timer_minus) - 3600 / trunc " 2" s0
			(L.S.Time) (L.L.cp_timer_minus) - 60 / l0 60 * - s1
			(L.S.Time) (L.L.cp_timer_minus) - 60 % s2
		{endif}
	{endif}

	l0 10 <
	{if}
		"0" l0 $IntToStr $+
	{else}
		l0 $IntToStr
	{endif}
	
	l1 10 <
	{if}
		":0" $+ l1 $IntToStr $+
	{else}
		":" $+ l1 $IntToStr $+
	{endif}
	
	l2 10 <
	{if}
		":0" $+ l2 $IntToStr $+
	{else}
		":" $+ l2 $IntToStr $+
	{endif}
	
	(S.$.timer)
	
	(L.L.cp_timer_mode) 0 =
	l0 23 > &&
	l1 59 > &&
	l2 59 > &&
	{if}
		(L.S.Time) (S.L.cp_timer_minus)
	{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)
{endif}


	(L.L.cp_fahrertuer_1_dragged) !
	{if}
		(L.L.cp_fahrertuer_1_pos) (L.S.Timegap) (L.L.cp_fahrertuer_1_speed) * + (S.L.cp_fahrertuer_1_pos)

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

		(L.L.cp_fahrertuer_1_pos) 0 >
		{if}
			(L.L.cp_fahrertuer_1_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_1_globalangle) * * + (S.L.cp_fahrertuer_1_speed)
		{endif}
	
		(L.L.cp_fahrertuer_1_speed) s0 (S.L.cp_fahrertuer_1_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.cp_fahrertuer_1_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.cp_fahrertuer_1_speed)
		{endif}


		(L.L.cp_fahrertuer_1_speed) 0 > (L.L.cp_fahrertuer_1_lastspeed) 0 < &&
		(L.L.cp_fahrertuer_1_speed) 0 < (L.L.cp_fahrertuer_1_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_fahrertuer_1_speed)
		{endif}	 
	
	{endif}

	(L.L.cp_fahrertuer_1_pos) 0 > (L.L.cp_fahrertuer_1_open) ! &&
	{if}
		(T.L.ev_fahrertuer_1_auf)
		1 (S.L.cp_fahrertuer_1_open)
	{endif}

	(L.L.cp_fahrertuer_1_pos) 0 = (L.L.cp_fahrertuer_1_open) &&
	{if}
		(T.L.ev_fahrertuer_1_zu)
		0 (S.L.cp_fahrertuer_1_open)
	{endif}

	(L.L.cp_fahrertuer_1_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_fahrertuer_1_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)
{endif}

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


	(L.L.cp_fahrertuer_2_dragged) !
	{if}
		(L.L.cp_fahrertuer_2_pos) (L.S.Timegap) (L.L.cp_fahrertuer_2_speed) * + (S.L.cp_fahrertuer_2_pos)

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

		(L.L.cp_fahrertuer_2_pos) 0 >
		{if}
			(L.L.cp_fahrertuer_2_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_2_globalangle) * * + (S.L.cp_fahrertuer_2_speed)
		{endif}
	
		(L.L.cp_fahrertuer_2_speed) s0 (S.L.cp_fahrertuer_2_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.cp_fahrertuer_2_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.cp_fahrertuer_2_speed)
		{endif}


		(L.L.cp_fahrertuer_2_speed) 0 > (L.L.cp_fahrertuer_2_lastspeed) 0 < &&
		(L.L.cp_fahrertuer_2_speed) 0 < (L.L.cp_fahrertuer_2_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_fahrertuer_2_speed)
		{endif}	 
	
	{endif}

	(L.L.cp_fahrertuer_2_pos) 0 > (L.L.cp_fahrertuer_2_open) ! &&
	{if}
		(T.L.ev_fahrertuer_zad_auf)
		1 (S.L.cp_fahrertuer_2_open)
	{endif}

	(L.L.cp_fahrertuer_2_pos) 0 = (L.L.cp_fahrertuer_2_open) &&
	{if}
		(T.L.ev_fahrertuer_zad_zu)
		0 (S.L.cp_fahrertuer_2_open)
	{endif}

	(L.L.cp_fahrertuer_2_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_fahrertuer_2_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)
{endif}


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

	(L.L.cp_fahrertuer_3_dragged) !
	{if}
		(L.L.cp_fahrertuer_3_pos) (L.S.Timegap) (L.L.cp_fahrertuer_3_speed) * + (S.L.cp_fahrertuer_3_pos)

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

		(L.L.cp_fahrertuer_3_pos) 0 >
		{if}
			(L.L.cp_fahrertuer_3_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_3_globalangle) * * + (S.L.cp_fahrertuer_3_speed)
		{endif}
	
		(L.L.cp_fahrertuer_3_speed) s0 (S.L.cp_fahrertuer_3_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.cp_fahrertuer_3_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.cp_fahrertuer_3_speed)
		{endif}


		(L.L.cp_fahrertuer_3_speed) 0 > (L.L.cp_fahrertuer_3_lastspeed) 0 < &&
		(L.L.cp_fahrertuer_3_speed) 0 < (L.L.cp_fahrertuer_3_lastspeed) 0 > && ||
		{if}
			0 (S.L.cp_fahrertuer_3_speed)
		{endif}	 
	
	{endif}

	(L.L.cp_fahrertuer_3_pos) 0 > (L.L.cp_fahrertuer_3_open) ! &&
	{if}
		(T.L.ev_fahrertuer_zad_auf)
		1 (S.L.cp_fahrertuer_3_open)
	{endif}

	(L.L.cp_fahrertuer_3_pos) 0 = (L.L.cp_fahrertuer_3_open) &&
	{if}
		(T.L.ev_fahrertuer_zad_zu)
		0 (S.L.cp_fahrertuer_3_open)
	{endif}

	(L.L.cp_fahrertuer_3_pos) 140 * 27 + 3.14 * 180 / sin (S.L.cp_fahrertuer_3_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)
{endif}
{end}

{macro:microphone_frame}

	(L.L.Clutch) 1.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) < && 
	(L.L.cp_proverka) ||
	{if}
		1 (S.L.cockpit_light_zentralschmierung)
		(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) (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) 
	1 (S.L.Refresh_Strings)
	
	(L.S.Weather_Temperature) s0 trunc " 3" $IntToStrEnh "." $+ 
	l0 abs l0 abs trunc - 10 * trunc " 1" $IntToStrEnh $+ "C" $+
	(S.$.cockpit_temperatur_out) 
	1 (S.L.Refresh_Strings)
	
{end}

{macro:luk_frame}
	(L.L.cp_luk_1)
	(L.L.cp_luk_1_rot) 0.1 > ||
	(L.L.cp_luk_1_trans) 0.1 > ||
	(S.L.cp_luk_1_meh)

	(L.L.cp_luk_2)
	(L.L.cp_luk_2_rot) 0.1 > ||
	(L.L.cp_luk_2_trans) 0.1 > ||
	(S.L.cp_luk_2_meh)

{end}

{macro:windows_frame}

	(L.S.Weather_Temperature) 10 <
	(L.L.Rain_Window_Norm_Wetness) ||
	{if}
		(L.S.Weather_Temperature) 0 >
		{if}
			(L.L.Glass_pot) (L.S.Timegap) 0.05 * + 0.8 min (S.L.Glass_pot)
			(L.L.cp_kn_obduv) (L.L.elec_busbar_main) &&
			{if}
				(L.L.Glass_pot_front) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot_front)
				(L.L.Glass_pot_front_noObduv) (L.S.Timegap) 0.001 * - 0 max (S.L.Glass_pot_front_noObduv)
			{else}
				(L.L.Glass_pot_front) (L.S.Timegap) 0.05 * + 1 min (S.L.Glass_pot_front)
				(L.L.Glass_pot_front_noObduv) (L.S.Timegap) 0.05 * + 1 min (S.L.Glass_pot_front_noObduv)
			{endif}
		{endif}
	{else}
		(L.L.cp_kn_obduv) (L.L.elec_busbar_main) &&
		{if}
			(L.L.Glass_pot_front) (L.S.Timegap) 0.05 * - 0 max (S.L.Glass_pot_front)
		{else}
			(L.L.Glass_pot_front) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot_front)
		{endif}
		(L.L.Glass_pot) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot)
		(L.L.Glass_pot_front_noObduv) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot_front_noObduv)
	{endif}
	
	(L.S.Weather_Temperature) 0 <
	{if}
		(L.L.Glass_ice) (L.S.Timegap) 0.01 * + 1 min (S.L.Glass_ice)
		(L.L.Glass_pot) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot)
		(L.L.Glass_pot_front) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot_front)
		(L.L.Glass_pot_front_noObduv) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_pot_front_noObduv)
		
		(L.L.cp_kn_obduv) (L.L.elec_busbar_main) &&
		{if}
			(L.L.Glass_ice_front) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_ice_front)
			(L.L.Glass_ice_front_noObduv) (L.S.Timegap) 0.005 * - 0 max (S.L.Glass_ice_front_noObduv)
		{else}
			(L.L.Glass_ice_front) (L.S.Timegap) 0.01 * + 1 min (S.L.Glass_ice_front)
			(L.L.Glass_ice_front_noObduv) (L.S.Timegap) 0.01 * + 1 min (S.L.Glass_ice_front_noObduv)
		{endif}
	{else}
		(L.L.Glass_ice) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_ice)
		(L.L.cp_kn_obduv) (L.L.elec_busbar_main) &&
		{if}
			(L.L.Glass_ice_front) (L.S.Timegap) 0.05 * - 0 max (S.L.Glass_ice_front)
			(L.L.Glass_ice_front_noObduv) (L.S.Timegap) 0.02 * - 0 max (S.L.Glass_ice_front_noObduv)
		{else}
			(L.L.Glass_ice_front) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_ice_front)
			(L.L.Glass_ice_front_noObduv) (L.S.Timegap) 0.01 * - 0 max (S.L.Glass_ice_front_noObduv)
		{endif}
	{endif}
{end}

{macro:sumki_frame} 

(L.L.humans_count) 3 > (S.L.cp_sumka_1_vis) 
(L.L.humans_count) 6 > (S.L.cp_sumka_2_vis) 
(L.L.humans_count) 9 > (S.L.cp_sumka_3_vis)  
(L.L.humans_count) 11 > (S.L.cp_sumka_4_vis) 
(L.L.humans_count) 12 > (S.L.cp_sumka_5_vis)
(L.L.humans_count) 17 > (S.L.cp_sumka_6_vis)
(L.L.humans_count) 21 > (S.L.cp_sumka_7_vis)
(L.L.humans_count) 23 > (S.L.cp_sumka_8_vis)
(L.L.humans_count) 25 > (S.L.cp_sumka_9_vis)
(L.L.humans_count) 27 > (S.L.cp_sumka_10_vis)
(L.L.humans_count) 29 > (S.L.cp_sumka_11_vis)
(L.L.humans_count) 31 > (S.L.cp_sumka_12_vis)
(L.L.humans_count) 34 > (S.L.cp_sumka_13_vis)
(L.L.humans_count) 37 > (S.L.cp_sumka_14_vis)
(L.L.humans_count) 45 > (S.L.cp_sumka_15_vis)

{end}

{macro:sumki_plus} 
 
(L.L.humans_count) 4 =
(L.L.humans_count) 7 =
||
(L.L.humans_count) 10 =
||
(L.L.humans_count) 12 =
||
(L.L.humans_count) 13 =
||

(L.L.humans_count) (L.L.humans_old_plus) >
&&

(L.L.door_1_hub)
&&

(L.L.auto_door_active2) !
&&
{if}
    0 (S.L.sumka_timer1)
    1 (S.L.auto_door_active1)
{endif}

(L.L.sumka_timer1) (L.S.Timegap) + (S.L.sumka_timer1)


(L.L.auto_door_active1)
{if}
    (L.L.sumka_timer1) 0 >=
    (L.L.sumka_timer1) 5 <=
    &&
	(S.L.cp_fahrertuer_2_pos)
	(S.L.cp_fahrertuer_3_pos)
	(S.L.cp_vod_helper_vis) 
   
    (L.L.sumka_timer1) 5 >
    {if}
        0 (S.L.auto_door_active1)
    {endif}
{endif}

(L.L.humans_count) (S.L.humans_old_plus)

{end}


{macro:sumki_minus} 
 
(L.L.humans_old_minus) 4 >=
(L.L.humans_count) 4 <
&&

(L.L.humans_old_minus) 7 >=
(L.L.humans_count) 7 <
&&
||
(L.L.humans_old_minus) 10 >=
(L.L.humans_count) 10 <
&&
||
(L.L.humans_old_minus) 12 >=
(L.L.humans_count) 12 <
&&
||
(L.L.humans_old_minus) 13 >=
(L.L.humans_count) 13 <
&&
||
(L.L.door_1_hub)
&&

(L.L.auto_door_active1) !
&&


{if}
    0 (S.L.sumka_timer2)
    1 (S.L.auto_door_active2)
{endif}


(L.L.sumka_timer2) (L.S.Timegap) + (S.L.sumka_timer2)

(L.L.auto_door_active2)
{if}
    (L.L.sumka_timer2) 0 >=
    (L.L.sumka_timer2) 5 <=
    &&
	(S.L.cp_fahrertuer_2_pos)
	(S.L.cp_fahrertuer_3_pos)
	(S.L.cp_vod_helper_vis)

    (L.L.sumka_timer2) 5 >
    {if}
        0 (S.L.auto_door_active2)
    {endif}
{endif}

(L.L.humans_count) (S.L.humans_old_minus)

{end}












 
 
{macro:kachanie_frame}
		(L.L.A_Trans_X) 9.81 / 1.5 min -1.5 max
		(L.L.cp_kachanie_x) - 0.05 *
		(L.S.Timegap) /
		(L.S.Timegap) 6 * /-/ exp
		(L.L.cp_kachanie_x_speed) * + (S.L.cp_kachanie_x_speed)
		(L.S.Timegap) * (L.L.cp_kachanie_x) + (S.L.cp_kachanie_x)
	{endif}
		(L.L.A_Trans_Y) 9.81 / 1.5 min -1.5 max
		(L.L.cp_kachanie_y) - 0.05 *
		(L.S.Timegap) /
		(L.S.Timegap) 6 * /-/ exp
		(L.L.cp_kachanie_y_speed) * + (S.L.cp_kachanie_y_speed)
		(L.S.Timegap) * (L.L.cp_kachanie_y) + (S.L.cp_kachanie_y)
	{endif}
{end}
