'################################################
'#########					   			#########
'######### 	  VDV Diagnosedisplay   	#########
'#########					   			#########
'#########	(C) 2017 Christian Rolle    #########
'#########					   			#########
'################################################

'############################################################################################################################
'Trigger & Mausevents:
'############################################################################################################################


{trigger:bus_dooraft}
	(L.L.auto_door2_int) !
	{if}
		0 (S.L.door2_bremse_halte_sw)
		(M.L.trg_bus_dooraft)
		(L.L.bremse_halte_sw)
		{if}
			(T.L.ev_VDV_on)
		{else}
			(T.L.ev_VDV_off)
		{endif}
	{else}
		(M.L.trg_bus_dooraft)
		(L.L.bremse_halte_sw)
		{if}
			(T.L.ev_VDV_on)
			1 (S.L.door2_bremse_halte_sw)
		{else}
			(T.L.ev_VDV_off)
			0 (S.L.door2_bremse_halte_sw)
		{endif}
	{endif}
{end}

{trigger:VDV_DIAG_button_down}
	1000000 (S.L.DIAG_Fadeout_time)
	(L.L.VDV_mode_switchable)
	{if}
		2 (S.L.VDV_state)
		(L.L.DIAG_Mode) 1 + 1 max (S.L.DIAG_Mode)
	{endif}
	1 (S.L.VDV_DIAG_switch_anim)
	(T.L.ev_VDV_toggle_on)
{end}

{trigger:VDV_DIAG_button_down_off}
	10 (S.L.DIAG_Fadeout_time)
	0 (S.L.VDV_DIAG_switch_anim)
	(T.L.ev_VDV_toggle_off)
{end}

{trigger:VDV_display_dimming_button_up}

	1 (S.L.Dimming)
	(T.L.ev_VDV_toggle_on)
{end}

{trigger:VDV_display_dimming_button_up_off}

	0 (S.L.Dimming)
	(T.L.ev_VDV_toggle_off)
{end}

{trigger:VDV_display_dimming_button_down}

	-1 (S.L.Dimming)
	(T.L.ev_VDV_toggle_on)
{end}

{trigger:VDV_position}
	(L.L.VDV_position_enabled) ! (S.L.VDV_position_enabled) s1
	1 =
	{if}
		(T.L.ev_VDV_on)
	{else}
		(T.L.ev_VDV_off)
	{endif}
{end}

{trigger:VDV_position_mov_drag}
	(L.L.VDV_position_enabled)
	{if}
		(L.S.mouse_y) -300 / (L.L.vdv_move_y) + 0.2 min -0.1 max (S.L.vdv_move_y)
		(L.S.mouse_x) 400 / (L.L.vdv_move_x) + 0.2 min 0 max (S.L.vdv_move_x)
	{endif}
{end}


{trigger:VDV_display_dimming_button_down_off}

	0 (S.L.Dimming)
	(T.L.ev_VDV_toggle_off)
{end}

{trigger:automatic_R}
	(L.L.antrieb_getr_gangvorwahl) 1 <= 
	{if}
		(L.L.antrieb_getr_gangvorwahl) 0 = !
		{if}
			(T.L.ev_gangwahltaster)
			(L.S.getTime) (S.L.antrieb_getr_gangwahlzeitpunkt)
		{endif}
		
		0 (S.L.antrieb_getr_gangvorwahl) (S.L.cockpit_gang1) (S.L.cockpit_gang2) (S.L.cockpit_gang3) (S.L.cockpit_gang4)	
		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 = !
	{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_gang4)
{end}


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


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

{end}


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


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


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

{trigger:automatic_3}
	(L.L.antrieb_getr_gangvorwahl) 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_gang1) (S.L.cockpit_gang2) (S.L.cockpit_gang4)
	{endif}
{end}


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


{trigger:automatic_D}
	(L.L.antrieb_getr_gangvorwahl) 0 >
	{if}
		(L.L.antrieb_getr_gangvorwahl) 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_gang4)
		0 (S.L.cockpit_gang1) (S.L.cockpit_gang2) (S.L.cockpit_gang3)		
	{endif}
{end}


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

{macro:VDV_init}
	(L.S.Weather_Temperature) (S.L.gearbox_temp)
	0 (S.L.VDV_state_timer) (S.L.VDV_state)
	5 (S.L.Display_light_Timer)
	1 (S.L.VDV_ready)
	0 1200 random (S.L.NextFunkTimer)
	0 20 random (S.L.FunkIndex)
{end}

{macro:VDV_frame}

'erstmal alle Macros laden:
	(M.L.odometer_frame)
	(M.L.oeldruck_frame)
	(M.L.gearbox_temp)
	(M.L.Display_dimming)


'########################################
'### Edit focus04
'########################################

(L.L.elec_busbar_main) !
{if}
	"VDV\VDV_blank_off.tga" (S.$.vdv_display_freigabe2) (S.$.vdv_display_freigabe)
{endif}

'########################################
'### Edit focus04 Ende
'########################################


(L.L.elec_busbar_main)
{if}


'Funksprüche:

		(L.L.NextFunkTimer) (L.S.Timegap) - (S.L.NextFunkTimer) 0 <=
		{if}
			(M.L.Funk_Playsound)
			0 20 random (S.L.FunkIndex)
			60 1800 random (S.L.NextFunkTimer)
		{endif}
		
'unterscheidung zwischen Nacht und Normalmode:
		(L.L.lights_stand)
		{if}
			"_N" (S.$.VDV_Lightmode)
			0 (S.L.Display_overlay_alphascale)
			(L.L.VDV_State) (S.L.VDV_txt_N_visible)
			1 (S.L.Refresh_Strings)
		{else}
			"" (S.$.VDV_Lightmode)
			(L.L.VDV_State) (S.L.VDV_txt_visible)
			1 (S.L.Refresh_Strings)
		{endif}

'##############################################################
'### VDV ready Beep per CTI (VDV_ready_off) ein/ausschalten ###
'##############################################################

(L.L.VDV_ready_off) 1 =
{if}		
		(L.L.door_0) 0.01 <
		(L.L.door_1) 0.01 < &&
		(L.L.door_2) 0.01 < &&
		(L.L.door_3) 0.01 < &&
		(L.L.door_4) 0.01 < &&
		(L.L.door_5) 0.01 < &&
		(L.L.Velocity) 0.01 < &&
		(L.L.VDV_ready) ! &&
		{if}
			(T.L.ev_ready)
			1 (S.L.VDV_ready)
		{endif}
		
		(L.L.door_0) 0.5 >
		(L.L.door_1) 0.5 > ||
		(L.L.door_2) 0.5 > ||
		(L.L.door_3) 0.5 > ||
		(L.L.door_4) 0.5 > ||
		(L.L.door_5) 0.5 > ||
		{if}
			0 (S.L.VDV_ready)
		{endif}
{endif}
'##############################################################
        
'       Status-Timer laufen lassen
        (L.L.bremse_halte) (L.L.bremse_feststell_sw) ||
        {if}
            (L.L.vdv_bremse_timer) (L.S.Timegap) + 0 max (S.L.vdv_bremse_timer)
        {else}
            (L.L.vdv_bremse_timer) (L.S.Timegap) - 0 min (S.L.vdv_bremse_timer)
        {endif}
        (L.L.vdv_bremse_state) !
        (L.L.vdv_bremse_timer) 1 > &&
        {if}
            1 (S.L.vdv_bremse_state)
        {endif}
        (L.L.vdv_bremse_state)
        (L.L.vdv_bremse_timer) -1 < &&
        {if}
            0 (S.L.vdv_bremse_state)
        {endif}

        (L.L.door_0) (L.L.door_1) ||
        {if}
            (L.L.vdv_door1_timer) (L.S.Timegap) + 0 max (S.L.vdv_door1_timer)
        {else}
            (L.L.vdv_door1_timer) (L.S.Timegap) - 0 min (S.L.vdv_door1_timer)
        {endif}
        (L.L.vdv_door1_state) !
        (L.L.vdv_door1_timer) 1 > &&
        {if}
            1 (S.L.vdv_door1_state)
        {endif}
        (L.L.vdv_door1_state)
        (L.L.vdv_door1_timer) -1 < &&
        {if}
            0 (S.L.vdv_door1_state)
        {endif}

        (L.L.door_2) (L.L.door_3) ||
        {if}
            (L.L.vdv_door2_timer) (L.S.Timegap) + 0 max (S.L.vdv_door2_timer)
        {else}
            (L.L.vdv_door2_timer) (L.S.Timegap) - 0 min (S.L.vdv_door2_timer)
        {endif}
        (L.L.vdv_door2_state) !
        (L.L.vdv_door2_timer) 1 > &&
        {if}
            1 (S.L.vdv_door2_state)
        {endif}
        (L.L.vdv_door2_state)
        (L.L.vdv_door2_timer) -1 < &&
        {if}
            0 (S.L.vdv_door2_state)
        {endif}

        (L.L.door_4) (L.L.door_5) ||
        {if}
            (L.L.vdv_door3_timer) (L.S.Timegap) + 0 max (S.L.vdv_door3_timer)
        {else}
            (L.L.vdv_door3_timer) (L.S.Timegap) - 0 min (S.L.vdv_door3_timer)
        {endif}
        (L.L.vdv_door3_state) !
        (L.L.vdv_door3_timer) 1 > &&
        {if}
            1 (S.L.vdv_door3_state)
        {endif}
        (L.L.vdv_door3_state)
        (L.L.vdv_door3_timer) -1 < &&
        {if}
            0 (S.L.vdv_door3_state)
        {endif}
		
		(L.L.VDV_state) 0 =
		{if}
'Setzen des INIT Timers:
			(L.L.VDV_state_timer) (L.S.Timegap) + (S.L.VDV_state_timer) s0
'Setzen der INIT Tauschtexturen:			
			l0 1 >
			l0 1.1 < &&
			{if}
				"VDV\VDV_init" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
			{endif}
			l0 1.1 >
			l0 1.3 < &&
			{if}
				"VDV\VDV_blank" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
			{endif}
			l0 1.3 >
			l0 1.4 < &&
			{if}
				"VDV\vdv_init_2" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
			{endif}
			l0 1.4 >
			l0 3.0 < &&
			{if}
				
				"VDV\VDV_blank" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
' Leuchtmelder Selftest:
				1 (S.L.Leuchtmelder_0) (S.L.Leuchtmelder_1) (S.L.Leuchtmelder_2) (S.L.Leuchtmelder_3)
				1 (S.L.Leuchtmelder_4) (S.L.Leuchtmelder_5) (S.L.Leuchtmelder_6) (S.L.Leuchtmelder_7)
				1 (S.L.Leuchtmelder_8) (S.L.Leuchtmelder_9)
			{endif}
			l0 3.0 >
			l0 3.1 < &&
			{if}
				"VDV\vdv_blank_black" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
' Leuchtmelder Selftest:
				0 (S.L.Leuchtmelder_0) (S.L.Leuchtmelder_1) (S.L.Leuchtmelder_2) (S.L.Leuchtmelder_3)
				(S.L.Leuchtmelder_4) (S.L.Leuchtmelder_5) (S.L.Leuchtmelder_6) (S.L.Leuchtmelder_7)
				(S.L.Leuchtmelder_8) (S.L.Leuchtmelder_9)
			{endif}
			l0 3.1 >
			l0 3.9 < &&
			{if}
				"VDV\VDV_blank" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
			{endif}
			l0 3.9 >
			l0 4 < &&
			{if}
				"VDV\vdv_init_3" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
			{endif}
			l0 4 >
			{if}
				"VDV\VDV_blank" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
				1 (S.L.VDV_state)
			{endif}
		{endif}
'###########################################################################################################################
'VDV State 1 -> Normalmode
'############################################################################################################################
		(L.L.VDV_state) 1 =
		{if}
			1 (S.L.vdv_gear_visible)
			(L.L.vdv_bremse_state)
' VDV Basetexture:
			{if}
				(L.L.tuersperre) -1 =
				{if}
					"DD-Mod\VDV\18m\VDV_stopmode_18m_X1" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
				{endif}
				(L.L.tuersperre) 1 =
				{if}
					"DD-Mod\VDV\18m\VDV_stopmode_18m_0X" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
				{endif}

				(L.L.tuersperre) 0 =
				{if}
					"DD-Mod\VDV\18m\VDV_stopmode_18m" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
				{endif}
				1 (S.L.VDV_mode_switchable)
				0 (S.L.retarder_visible)
				0 (S.L.haltew_visible)
' VDV Freigabe:				

'########################################
'### Edit PingPong
'########################################

'########################################
'### Edit Focus
'########################################

(L.L.door_freigabe)
(L.L.Velocity) 0.1 < &&
{if}
		(L.L.freigabe_timer) (L.S.Timegap) + 1 min (S.L.freigabe_timer)
		0.5 <
		{if}
			1 (S.L.freigabe2_timer)
		{else}
			0 (S.L.freigabe2_timer) (S.L.freigabe_visible) (S.L.freigabe2_visible)
		{endif}
		(L.L.freigabe_timer) 1 =
		{if}
			0 (S.L.freigabe_timer) (S.L.freigabe_visible) (S.L.freigabe2_visible)
		{endif}

		"DD-Mod\VDV\VDV_freigabe2" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_freigabe2)
		"VDV\VDV_freigabe" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_freigabe)

		(L.L.freigabe2_timer)
		{if}		
		(L.L.vdv_door2_state) !
		(L.L.auto_door2_int) &&
		{if}
				1 (S.L.freigabe2_visible)
		{endif}
		(L.L.vdv_door3_state) !
		{if}
				1 (S.L.freigabe_visible)
		{endif}
	{endif}
{else}
0 (S.L.freigabe_visible) (S.L.freigabe2_visible)
{endif}

'########################################
'### Edit PingPong Ende
'########################################

'########################################
'### Edit Focus Ende
'########################################


' VDV Türen:
				

				(L.L.vdv_door1_state)
				{if}
					(L.L.tuersperre) -1 =
					{if}
						"DD-Mod\VDV\18m\VDV_tuer1_X1" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_door0a)
					{endif}

					(L.L.tuersperre) 1 =
					{if}
						"DD-Mod\VDV\18m\VDV_tuer1_0X" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_door0a)
					{endif}
		
					(L.L.tuersperre) 0 =
					{if}
						"VDV\VDV_tuer1_18m" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_door0a)
					{endif}

					1 (S.L.door0_visible)
				{else}
					0 (S.L.door0_visible)
				{endif}


				(L.L.vdv_door2_state)
				{if}
					"VDV\VDV_tuer2_18m" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_door0b)
					1 (S.L.door1_visible)
				{else}
					0 (S.L.door1_visible)
				{endif}


				(L.L.vdv_door3_state)
				{if}
					"VDV\VDV_tuer3_18m" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_door2)
					1 (S.L.door01_visible)
				{else}
					0 (S.L.door01_visible)
				{endif}

				(L.L.bremse_halte)
				{if}
					"VDV\VDV_halte" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_door1)				
					1 (S.L.door23_visible)
				{else}
					0 (S.L.door23_visible)
				{endif}
				(L.L.kneel_timer) 0 >
				{if}
					(L.L.bremse_suspension_drainvalve_0_R)
					(L.L.bremse_suspension_fillvalve_0_R) ||
					{if}
						(L.L.kneeling_blinkgeber) (S.L.VDV_kneeling_visible)
						"VDV\VDV_kneel_updown" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_kneeling)
					{else}
						(C.L.bremse_level_setpoint) (L.L.bremse_level_setpoint) = !
						{if}
							"VDV\VDV_kneel_down" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_kneeling)
							1 (S.L.VDV_kneeling_visible)
							0 (S.L.kneeling_pressed)
						{endif}
					{endif}
				{else}
					0 (S.L.VDV_kneeling_visible)
				{endif}
			{else}
				"VDV\VDV_blank" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
				0 (S.L.VDV_mode_switchable) (S.L.door23_visible) (S.L.door0_visible) (S.L.door1_visible) (S.L.door01_visible)
				0 (S.L.VDV_kneeling_visible)
' VDV Pictogramm Retarder:
				(L.L.antrieb_retarder)
				{if}
					"VDV\VDV_Retarder" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_retarder)
					1 (S.L.retarder_visible)
				{else}
					0 (S.L.retarder_visible)
				{endif}
' VDV Pictogramm Haltewunsch:
				(L.L.haltewunsch)
				(L.L.haltewunsch_23) ||
				(L.L.haltewunsch_01) ||
				(L.L.haltewunsch_45) ||
				{if}
					"VDV\VDV_haltew" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_haltew)
					1 (S.L.haltew_visible)
				{else}
					0 (S.L.haltew_visible)
				{endif}
			{endif}
' VDV Pictogramm Feststellbremse:
			(L.L.bremse_feststell_sw)
			{if}
				"VDV\VDV_feststell" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_misctexture0)
				1 (S.L.bremse_feststell_visible)
			{else}
				0 (S.L.bremse_feststell_visible)
			{endif}
' VDV Temperaturstring:
			(L.L.lights_stand)
			{if}
				(L.L.engine_temperature) 99 <=
				{if}
					(L.L.engine_temperature) 0 <=
					{if}
						(L.L.engine_temperature) -10 <=
						{if}
							"" (L.L.engine_temperature) abs $IntToStr 1 $cutEnd (S.$.nightmode_puffer_1) (M.L.nightmode_conv1)
							"" (L.L.engine_temperature) abs $IntToStr 1 $cutBegin (S.$.nightmode_puffer_2) (M.L.nightmode_conv2)
							"" "k" (L.$.nightmode_puffer_1) $+ (L.$.nightmode_puffer_2) $+ (S.$.engine_temp)
						{else}
							"" (L.L.engine_temperature) abs $IntToStr (S.$.nightmode_puffer_1) (M.L.nightmode_conv1)
							"" "k" (L.$.nightmode_puffer_1) $+ (S.$.engine_temp)
						{endif}
					{else}
						(L.L.engine_temperature) 10 >=
						{if}
							"" (L.L.engine_temperature) abs $IntToStr 1 $cutEnd (S.$.nightmode_puffer_1) (M.L.nightmode_conv1)
							"" (L.L.engine_temperature) abs $IntToStr 1 $cutBegin (S.$.nightmode_puffer_2) (M.L.nightmode_conv2)
							"" (L.$.nightmode_puffer_1) (L.$.nightmode_puffer_2) $+ (S.$.engine_temp)
						{else}
							"" (L.L.engine_temperature) abs $IntToStr (S.$.nightmode_puffer_1) (M.L.nightmode_conv1)
							"" (L.$.nightmode_puffer_1) (S.$.engine_temp)
						{endif}
					{endif}
				{else}
					{if}			
						"" "kk" (S.$.engine_temp)
					{endif}
				{endif}
				(L.S.Weather_Temperature) 0 <=
				{if}
					"" (L.S.Weather_Temperature) abs " 2" $IntToStrEnh 1 $cutEnd (S.$.nightmode_puffer_1) (M.L.nightmode_conv1)
					"" (L.S.Weather_Temperature) abs " 2" $IntToStrEnh 1 $cutBegin (S.$.nightmode_puffer_2) (M.L.nightmode_conv2)
					"" "k" (L.$.nightmode_puffer_1) $+ (L.$.nightmode_puffer_2) $+ (S.$.weather_temp)
				{else}
					"" (L.S.Weather_Temperature) abs " 2" $IntToStrEnh 1 $cutEnd (S.$.nightmode_puffer_1) (M.L.nightmode_conv1)
					"" (L.S.Weather_Temperature) abs " 2" $IntToStrEnh 1 $cutBegin (S.$.nightmode_puffer_2) (M.L.nightmode_conv2)
					"" (L.$.nightmode_puffer_1) (L.$.nightmode_puffer_2) $+ (S.$.weather_temp)
				{endif}
			{else}
				(L.L.engine_temperature) 99 <=
				{if}
					"" (L.L.engine_temperature) $IntToStr (S.$.engine_temp)
				{else}
						"" "--" (S.$.engine_temp)
				{endif}
				"" (L.S.Weather_Temperature) $IntToStr $+ (S.$.weather_temp)
			{endif}
				"" (L.$.engine_temp) "@" $+ (L.$.weather_temp) $+ (S.$.VDV_Temp_Font)
			"VDV\VDV_temperatur" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_misctexture1)			
' VDV Pictogramm Getriebe:
			(L.L.cockpit_gangR)
			{if}
				"VDV\VDV_gearbox_R" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_geartexture)
			{endif}
			
			(L.L.cockpit_gangR) !
			{if}
				(L.L.antrieb_getr_aktugang) s0
				l0 0 =
				{if}
					(L.L.antrieb_getr_gangvorwahl) 5 =
					{if}
						"VDV\VDV_gearbox_1" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_geartexture)
					{else}
						"VDV\VDV_gearbox_N" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_geartexture)
					{endif}
				{endif}
				l0 1 =			
				{if}
					"VDV\VDV_gearbox_1" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_geartexture)
				{endif}	
				l0 2 =
				{if}
					"VDV\VDV_gearbox_2" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_geartexture)
				{endif}	
				l0 3 =
				{if}
					"VDV\VDV_gearbox_3" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_geartexture)
				{endif}	
				l0 4 =
				{if}
					"VDV\VDV_gearbox_4" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_geartexture)
				{endif}	
				
'	Auskommentiert da Voith - wer ein ZF einbauen möchte muss hier nur noch die betroffenen Gänge entsperren!
'				l0 5 =
'				{if}
'					"VDV\VDV_gearbox_5" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_geartexture)
'				{endif}	
'				l0 6 =
'				{if}
'					"VDV\VDV_gearbox_6" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_geartexture)
'				{endif}	
			{endif}
		{else}
'	Löschen der Pictogramme, wenn Strom aus und/oder VDV-State nicht Drivemode
			0 (S.L.vdv_gear_visible) (S.L.door0_visible) (S.L.door1_visible) (S.L.door23_visible) (S.L.bremse_feststell_visible)
			0 (S.L.door01_visible) (S.L.door0_visible)
			0 (S.L.VDV_kneeling_visible)
		{endif}
'############################################################################################################################
'VDV State 2 -> Diagnosedisplay
'############################################################################################################################
		(L.L.VDV_state) 2 =
		{if}
'	VDV Diagnosebildschirm 1 inkl. Textfeldern:
'	Bremsdruck
			(L.L.DIAG_Mode) 1 =
			(L.L.DIAG_Mode) ! ||
			{if}
				"VDV\VDV_DIAG_1" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
				(L.L.lights_stand) !
				{if}
					(L.L.bremse_p_brzyl_VA) (F.L.pressure_balken) trunc s0
					(L.L.bremse_p_brzyl_HA) (F.L.pressure_balken) trunc s1
					(L.L.bremse_p_tank01) (L.L.bremse_p_tank02) + 2 / (F.L.pressure_balken) trunc s2
					(L.L.bremse_p_tank03) (L.L.bremse_p_tank04) + 2 / (F.L.pressure_balken) trunc s3
					"X" l0 $* (S.$.VDV_DIAG_Font)
					"X" l1 $* (S.$.VDV_DIAG_Font_2)
					"X" l2 $* (S.$.VDV_DIAG_Font_3)
					"X" l3 $* (S.$.VDV_DIAG_Font_4)
					1 (S.L.DIAG_balken_1) (S.L.DIAG_balken_2) (S.L.DIAG_balken_3) (S.L.DIAG_balken_4)
					0 (S.L.DIAG_balken_5) (S.L.DIAG_balken_6)
				{else}
					(L.L.bremse_p_brzyl_VA) (F.L.pressure_balken) trunc s0
					(L.L.bremse_p_brzyl_HA) (F.L.pressure_balken) trunc s1
					(L.L.bremse_p_tank01) (L.L.bremse_p_tank02) + 2 / (F.L.pressure_balken) trunc s2
					(L.L.bremse_p_tank03) (L.L.bremse_p_tank04) + 2 / (F.L.pressure_balken) trunc s3
					"l" l0 $* (S.$.VDV_DIAG_Font)
					"l" l1 $* (S.$.VDV_DIAG_Font_2)
					"l" l2 $* (S.$.VDV_DIAG_Font_3)
					"l" l3 $* (S.$.VDV_DIAG_Font_4)
					1 (S.L.DIAG_balken_1) (S.L.DIAG_balken_2) (S.L.DIAG_balken_3) (S.L.DIAG_balken_4)
					0 (S.L.DIAG_balken_5) (S.L.DIAG_balken_6)
				{endif}
			{endif}
'	VDV Diagnosebildschirm 2 inkl. Textfeldern:
'	Tankanzeige
			(L.L.DIAG_Mode) 2 =
			{if}
				(L.L.lights_stand) !
				{if}
					"VDV\VDV_DIAG_2" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
					(L.L.engine_tank_content) (F.L.tank_balken) trunc s0
					"X" l0 $* (S.$.VDV_DIAG_Font_6)
					0 (S.L.DIAG_balken_1) (S.L.DIAG_balken_2) (S.L.DIAG_balken_3) (S.L.DIAG_balken_4)
					0 (S.L.DIAG_balken_5)
					1 (S.L.DIAG_balken_6)
				{else}
					"VDV\VDV_DIAG_2" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
					(L.L.engine_tank_content) (F.L.tank_balken) trunc s0
					"l" l0 $* (S.$.VDV_DIAG_Font_6)
					0 (S.L.DIAG_balken_1) (S.L.DIAG_balken_2) (S.L.DIAG_balken_3) (S.L.DIAG_balken_4)
					0 (S.L.DIAG_balken_5)
					1 (S.L.DIAG_balken_6)
				{endif}
			{endif}
'	VDV Diagnosebildschirm 3 inkl. Textfeldern:
'	Öldruck und Motortemperatur
			(L.L.DIAG_Mode) 3 =
			{if}
				(L.L.lights_stand) !
				{if}
					"VDV\VDV_DIAG_3" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
					(L.L.VDV_oeldruck) (F.L.oeldruck_balken) trunc s0
					(L.L.engine_temperature) (F.L.engine_balken) trunc s1
					"X" l0 $* (S.$.VDV_DIAG_Font_5)
					"X" l1 $* (S.$.VDV_DIAG_Font_6)
					0 (S.L.DIAG_balken_1) (S.L.DIAG_balken_2) (S.L.DIAG_balken_3) (S.L.DIAG_balken_4)
					1 (S.L.DIAG_balken_5) (S.L.DIAG_balken_6)
				{else}
					"VDV\VDV_DIAG_3" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
					(L.L.VDV_oeldruck) (F.L.oeldruck_balken) trunc s0
					(L.L.engine_temperature) (F.L.engine_balken) trunc s1
					"l" l0 $* (S.$.VDV_DIAG_Font_5)
					"l" l1 $* (S.$.VDV_DIAG_Font_6)				
					0 (S.L.DIAG_balken_1) (S.L.DIAG_balken_2) (S.L.DIAG_balken_3) (S.L.DIAG_balken_4)
					1 (S.L.DIAG_balken_5) (S.L.DIAG_balken_6)
				{endif}
			{endif}
'	VDV Diagnosebildschirm 4 inkl. Textfeldern:
'	Getriebetemperatur
			(L.L.DIAG_Mode) 4 =
			{if}
				(L.L.lights_stand) !
				{if}
					"VDV\VDV_DIAG_4" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
					(L.L.gearbox_temp) (F.L.gearbox_balken) trunc s0
					"X" l0 $* (S.$.VDV_DIAG_Font_6)
					0 (S.L.DIAG_balken_1) (S.L.DIAG_balken_2) (S.L.DIAG_balken_3) (S.L.DIAG_balken_4) (S.L.DIAG_balken_5)
					1 (S.L.DIAG_balken_6)
				{else}
					"VDV\VDV_DIAG_4" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
					(L.L.gearbox_temp) (F.L.gearbox_balken) trunc s0
					"l" l0 $* (S.$.VDV_DIAG_Font_6)
					0 (S.L.DIAG_balken_1) (S.L.DIAG_balken_2) (S.L.DIAG_balken_3) (S.L.DIAG_balken_4) (S.L.DIAG_balken_5)
					1 (S.L.DIAG_balken_6)
				{endif}
			{endif}
'	Rücksetzen des VDV Modi
			(L.L.DIAG_Mode) 5 =
			{if}
				0 (S.L.DIAG_Mode)
				1 (S.L.VDV_state)
				(M.L.TXT_CLEAR)
			{endif}
			(L.L.DIAG_Fadeout_time) (L.S.Timegap) - (S.L.DIAG_Fadeout_time)
			(L.L.DIAG_Fadeout_time) 0 <=
			(L.L.DIAG_Mode) 0 = ! &&
			{if}
				0 (S.L.DIAG_Mode)
				(M.L.TXT_CLEAR)
				1 (S.L.VDV_state)
			{endif}
		{endif}

		(L.L.VDV_state) 
		{if}
' VDV Leuchtmelder STOP:
			(L.L.antrieb_failure_general)
			(L.L.articulation_knickschutz_warning)
			{if}
				1 (S.L.Leuchtmelder_0)
				(L.L.warn_antirepeat) !
				{if}
					(T.L.ev_stoermeldung_rot)
					1 (S.L.warn_antirepeat)
				{endif}
			{else}
				0 (S.L.Leuchtmelder_0)
				0 (S.L.warn_antirepeat)
			{endif}

' VDV Leuchtmelder WARN:
			0 (S.L.Leuchtmelder_1)
' VDV Leuchtmelder BLINK:
			(L.L.lights_sw_fahrschulblinker)
			(L.L.bremse_halte) &&
			(L.L.lights_sw_warnblinker) ! &&
			{if}
				0 (S.L.Leuchtmelder_2)
			{else}
				(L.L.lights_blinkgeber) (S.L.Leuchtmelder_2)
			{endif}
' VDV Leuchtmelder FERN:
			(L.L.lights_fern) (S.L.Leuchtmelder_3)
' VDV Leuchtmelder FEST:
			(L.L.bremse_p_Brzyl_FBA) 650000 <
			(L.L.elec_busbar_main) *
			(L.L.bremse_feststell_sw) ||
			{if}
				1 (S.L.Leuchtmelder_4)
			{else}
				0 (S.L.Leuchtmelder_4)
			{endif}
' VDV Leuchtmelder HALT:
			(L.L.haltewunsch) (L.L.haltewunsch_45) (L.L.haltewunsch_23) (L.L.haltewunsch_01) || || || (S.L.Leuchtmelder_5)
			
			(L.L.engine_ASR_eingriff)
			(L.L.bremse_ABS_eingriff_0R) ||
			(L.L.bremse_ABS_eingriff_0L) ||
			(L.L.bremse_ABS_eingriff_1R) ||
			(L.L.bremse_ABS_eingriff_1L) ||
			{if}
				1 (S.L.Leuchtmelder_6)
			{else}
				0 (S.L.Leuchtmelder_6)
			{endif}
' VDV Leuchtmelder Motor:
			(L.L.lights_sw_fahrschulblinker)
			(L.L.bremse_halte) &&
			{if}
				(L.L.lights_blinkgeber) (S.L.Leuchtmelder_7)
			{else}
				(L.L.lights_warnblinkgeber) (S.L.Leuchtmelder_7)
			{endif}
		{endif}
	
	{else}
		0 (S.L.VDV_state) (S.L.door0_visible) (S.L.door1_visible) (S.L.door23_visible)
		0 (S.L.bremse_feststell_visible) (S.L.vdv_gear_visible)
		"VDV\VDV_blank" (L.$.VDV_Lightmode) $+ ".tga" $+ (S.$.vdv_display_basetexture)
		0 (S.L.Leuchtmelder_0) (S.L.Leuchtmelder_1) (S.L.Leuchtmelder_2) (S.L.Leuchtmelder_3) (S.L.Leuchtmelder_4) (S.L.Leuchtmelder_5)
		(S.L.Leuchtmelder_6) (S.L.Leuchtmelder_7) (S.L.Leuchtmelder_8) (S.L.Leuchtmelder_9)
	{endif}
{end}

{macro:TXT_CLEAR}
	0 (S.L.DIAG_balken_1) (S.L.DIAG_balken_2) (S.L.DIAG_balken_3) (S.L.DIAG_balken_4)
	0 (S.L.DIAG_balken_5) (S.L.DIAG_balken_6)
{end}

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

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

{macro:traegheit}
	l0 l1 > 
	{if}
		l2 (L.S.Timegap) * 1 min -1 max s4
	{else}
		l3 (L.S.Timegap) * 1 min -1 max s4
	{endif}
	l0
	l1
	- l4 *
	l1 + s1
{end}

{macro:gearbox_temp}
'	Temperatursimulation Getriebe:
'	Retarder generiert Wärme bei benutzung:
	(L.L.antrieb_retarder)
	(L.L.Brake) ||
	{if}
		(L.L.retarder_ontime) (L.S.Timegap) 10 / + (S.L.retarder_ontime)
	{else}
'	Und er verliert Sie, wenn er nichtmehr läuft:
		(L.L.retarder_ontime) 0 >=
		{if}
			(L.L.retarder_ontime) (L.S.Timegap) 30 / - (S.L.Retarder_ontime)
		{endif}
	{endif}
'	Und das Gleiche für das Getriebe selbst:
	(L.L.Throttle)
	(L.L.Velocity) &&
	{if}
		(L.L.Antrieb_ontime) (L.S.Timegap) 10 / + (S.L.Antrieb_ontime)
	{else}
		(L.L.Antrieb_ontime) 0 >=
		{if}
			(L.L.Antrieb_ontime) (L.S.Timegap) 30 / - (S.L.Antrieb_ontime)
		{endif}
	{endif}
	(L.L.gearbox_temp) (F.L.gearbox_cooling) s0
	
	(L.S.Weather_Temperature) (L.L.retarder_ontime) (L.L.Antrieb_ontime) + + l0 - (S.L.gearbox_temp)
{end}

{macro:Display_dimming}
'Dimmer fürs Display:
		(L.L.Dimming) -1 =
		(L.L.Display_light_Timer) 8 <= &&
		{if}
			(L.L.Display_light_Timer) (L.S.Timegap) + (S.L.Display_light_Timer)
		{endif}
		(L.L.Dimming) 1 =
		(L.L.Display_light_Timer) 0 >= &&
		{if}
			(L.L.Display_light_Timer) (L.S.Timegap) - (S.L.Display_light_Timer)
		{endif}
		"" "VDV\VDV_alpha.tga" $+ (S.$.vdv_display_blendtexture)
		(L.L.Display_light_Timer) trunc 10 / (S.L.Display_overlay_alphascale)
{end} 		
	
{macro:tacho_frame}
	(L.L.Velocity) (F.L.dashboard_tachoposition) (S.L.dashboard_tachoanim)
{end}

{macro:odometer_frame}

'Uhrzeit:
	(L.S.Time) 3600 / trunc " 2" s0
	(L.S.Time) 60 / l0 60 * - s1 
 
	l0 10 <
	{if}
		"0" l0 $IntToStr $+
	{else}
		l0 $IntToStr
	{endif}
 
	l1 10 <
	{if}
		":0" $+ l1 $IntToStr $+
	{else}
		":" $+ l1 $IntToStr $+
	{endif}
 
	(S.$.Uhrzeit)
'Odometer
    ""
	(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.km_counter_km) trunc " 7" $IntToStrEnh 6 $SetLengthR
	"." $+
	(L.$.km_counter_m) 1 $SetLengthL $+
	(S.$.Odometer)
'Kombinieren:
	(L.$.Odometer) "@" $+ (L.$.Uhrzeit) $+ (S.$.VDV_Odometer)
{end} 

{macro:nightmode_conv1}
	(L.$.nightmode_puffer_1) "1" $=
	{if}
		"a" (S.$.nightmode_puffer_1)
	{endif}
	(L.$.nightmode_puffer_1) "2" $=
	{if}
		"b" (S.$.nightmode_puffer_1)
	{endif}
	(L.$.nightmode_puffer_1) "3" $=
	{if}
		"c" (S.$.nightmode_puffer_1)
	{endif}
	(L.$.nightmode_puffer_1) "4" $=
	{if}
		"d" (S.$.nightmode_puffer_1)
	{endif}
	(L.$.nightmode_puffer_1) "5" $=
	{if}
		"e" (S.$.nightmode_puffer_1)
	{endif}
	(L.$.nightmode_puffer_1) "6" $=
	{if}
		"f" (S.$.nightmode_puffer_1)
	{endif}
	(L.$.nightmode_puffer_1) "7" $=
	{if}
		"g" (S.$.nightmode_puffer_1)
	{endif}
	(L.$.nightmode_puffer_1) "8" $=
	{if}
		"h" (S.$.nightmode_puffer_1)
	{endif}
	(L.$.nightmode_puffer_1) "9" $=
	{if}
		"i" (S.$.nightmode_puffer_1)
	{endif}
	(L.$.nightmode_puffer_1) "0" $=
	{if}
		"j" (S.$.nightmode_puffer_1)
	{endif}
{end}

{macro:nightmode_conv2}
	(L.$.nightmode_puffer_2) "1" $=
	{if}
		"a" (S.$.nightmode_puffer_2)
	{endif}
	(L.$.nightmode_puffer_2) "2" $=
	{if}
		"b" (S.$.nightmode_puffer_2)
	{endif}
	(L.$.nightmode_puffer_2) "3" $=
	{if}
		"c" (S.$.nightmode_puffer_2)
	{endif}
	(L.$.nightmode_puffer_2) "4" $=
	{if}
		"d" (S.$.nightmode_puffer_2)
	{endif}
	(L.$.nightmode_puffer_2) "5" $=
	{if}
		"e" (S.$.nightmode_puffer_2)
	{endif}
	(L.$.nightmode_puffer_2) "6" $=
	{if}
		"f" (S.$.nightmode_puffer_2)
	{endif}
	(L.$.nightmode_puffer_2) "7" $=
	{if}
		"g" (S.$.nightmode_puffer_2)
	{endif}
	(L.$.nightmode_puffer_2) "8" $=
	{if}
		"h" (S.$.nightmode_puffer_2)
	{endif}
	(L.$.nightmode_puffer_2) "9" $=
	{if}
		"i" (S.$.nightmode_puffer_2)
	{endif}
	(L.$.nightmode_puffer_2) "0" $=
	{if}
		"j" (S.$.nightmode_puffer_2)
	{endif}
{end}

{macro:trg_bus_dooraft}
	(L.L.bremse_halte_sw) ! (S.L.bremse_halte_sw)
{end}


{macro:Funk_Playsound}
	"" "..\..\Announcements\" 0 (M.V.GetDepotStringGlobal) $+ "\" $+ "Funk\Funkspruch_" $+ (L.L.FunkIndex) $IntToStr $+
	".wav" $+
	(T.F.ev_Funkspruch)
{end}


	