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

'Simuliert alle unmittelbar mit dem Armaturenbrett zusammenhängenden Funktionen

'(c) 23.10.2009 Rüdiger Hülsmann
'(c) 15.04.2010 Marcel Kuhnt

'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
'- DMG1978 & busfreak 14.06.2011 Gear-button lights
'- Ikarus V134 /a.k.a. Cpt.Dave dd.mm.2011 Doorbell - Ajtócsengõ script
'- Ikarus V134 /a.k.a. Cpt.Dave 18.09.2011 Automatic door break - Ajtócsengõ script
'------------------------------------------------------------------------------------------


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

	
'{trigger:csengo}
'        (L.L.door_ajtocsengo1) (L.L.door_ajtocsengo2) (L.L.door_ajtocsengo3) ! (L.L.elec_busbar_main) &&
'        1 (S.L.door_ajtocsengo1) (S.L.door_ajtocsengo2) (S.L.door_ajtocsengo3)
'{end}

'{trigger:csengo_off}
'        (L.L.door_ajtocsengo1) (L.L.door_ajtocsengo2) (L.L.door_ajtocsengo3) (L.L.elec_busbar_main) &&
'        0 (S.L.door_ajtocsengo1) (S.L.door_ajtocsengo2) (S.L.door_ajtocsengo3)
'{end}
	
{trigger:csengo}
	
'		(L.L.door_ajtocsengo) ! (L.L.elec_busbar_main) &&
		(L.L.door_ajtocsengo) !
		{if}
			1 (S.L.door_ajtocsengo)
		{endif}
		1 (S.L.door_ajtocsengo_g)
	
{end}

{trigger:cp_legbefuvo_toggle}
	(L.L.cp_legbefuvo_sw) ! (S.L.cp_legbefuvo_sw) s1
{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}
't1:138; t2:270
	(L.L.cp_rollo_pos) 0.138 >=
	{if}
		(L.L.nrl_t_1_visibility) 0 =
		{if}
			1 (S.L.nrl_t_1_visibility)
		{endif}
	{endif}
	(L.L.cp_rollo_pos) 0.32 >=
	{if}
		(L.L.nrl_t_2_visibility) 0 =
		{if}
			1 (S.L.nrl_t_2_visibility)
		{endif}
	{endif}
	(L.L.cp_rollo_pos) 0.5 >=
	{if}
		(L.L.nrl_t_3_visibility) 0 =
		{if}
			1 (S.L.nrl_t_3_visibility)
		{endif}
	{endif}
	(L.L.cp_rollo_pos) 0.68 >=
	{if}
		(L.L.nrl_t_4_visibility) 0 =
		{if}
			1 (S.L.nrl_t_4_visibility)
		{endif}
	{endif}
	(L.L.cp_rollo_pos) 0.86 >=
	{if}
		(L.L.nrl_t_5_visibility) 0 =
		{if}
			1 (S.L.nrl_t_5_visibility)
		{endif}
	{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}


'----------------------
'	Frame
'----------------------

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

	(M.L.rollo_frame)

{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}
	(L.L.cp_rollo_pos) 0.138 <=
	{if}
		(L.L.nrl_t_1_visibility) 1 =
		{if}
			0 (S.L.nrl_t_1_visibility)
		{endif}
	{endif}
	(L.L.cp_rollo_pos) 0.32 <=
	{if}
		(L.L.nrl_t_2_visibility) 1 =
		{if}
			0 (S.L.nrl_t_2_visibility)
		{endif}
	{endif}
	(L.L.cp_rollo_pos) 0.5 <=
	{if}
		(L.L.nrl_t_3_visibility) 1 =
		{if}
			0 (S.L.nrl_t_3_visibility)
		{endif}
	{endif}
	(L.L.cp_rollo_pos) 0.68 <=
	{if}
		(L.L.nrl_t_4_visibility) 1 =
		{if}
			0 (S.L.nrl_t_4_visibility)
		{endif}
	{endif}
	(L.L.cp_rollo_pos) 0.86 <=
	{if}
		(L.L.nrl_t_5_visibility) 1 =
		{if}
			0 (S.L.nrl_t_5_visibility)
		{endif}
	{endif}
{end}


