Rail3D*

   

 

Sample Signal Script



// Test script for signal

Init()
{
	debug.printL("Signal Initialising");
	int iID=0;
}

OnTrain()
{
	debug.clear();
	debug.printTime();
	debug.printL("Signal.OnTrain()");

// Read some stuff about the train
	debug.print("   ");
	debug.print(Train.GetType());
	debug.print("   ");
	debug.print(Train.GetNumber());
	debug.print("   ");
	debug.print(Train.GetRoute());
	debug.print("   ");
	debug.printL(Train.GetSpeed());


// State of this signal

	debug.print("   ");
	if(Signal.IsOn())
	{
		debug.print("ON ");
	}
	if(Signal.IsCau())
	{
		debug.print("Cau ");
	}
	if(Signal.IsCau2())
	{
		debug.print("Cau2 ");
	}
	if(Signal.IsJct())
	{
		debug.print("Jct ");
	}
	if(Signal.IsJct2())
	{
		debug.print("Jct2 ");
	}


// Code for setting train speed limit		
	float a=Train.GetLimit();
	debug.print("   ");
	debug.printL(a);

	if(Signal.IsJct() && (a>8))
	{
		Train.SetLimit(8);
	}


	if(iID)
	{
		debug.print("ID: ");
		debug.printL(iID);
	}


	debug.printL("");
}

OnSetLamps()
{
	debug.print("");


// State of this signal

	debug.print("   ");
	if(Signal.IsCau())
	{
		debug.print("Cau ");
		a=1;
		while(a<6)
		{
			Signal.SetLamp(a,a*30,100,255,1);
			a++;
		}
	}
	if(Signal.IsCau2())
	{
		debug.print("Cau2 ");
		a=1;
		while(a<6)
		{
			Signal.UnsetLamp(a);
			a++;
		}
	}
	if(Signal.IsJct())
	{
		debug.print("Jct ");
		a=1;
		while(a<6)
		{
			Signal.SetLamp(a,255,255,255,1);
			a++;
		}
	}
	if(Signal.IsJct2())
	{
		debug.print("Jct2 ");
		a=1;
		while(a<6)
		{
			Signal.UnsetLamp(a);
			a++;
		}
	}
	if(Signal.IsOn())
	{
		debug.print("ON ");
		a=1;
		while(a<6)
		{
			Signal.UnsetLamp(a);
			a++;
		}
	}


	debug.printL("");
}


import