HowTo/Example Station Script

From TrainzOnline
Jump to: navigation, search

This is the Station.gs script for the example station asset:

include "GenericPassengerStation.gs"
   
class Station isclass GenericPassengerStation
{
 
  bool TriggerSupportsMassStoppedLoad(Vehicle vehicle, string triggerName)
  {
    bool vehicleToTrain = vehicle.GetFacingRelativeToTrain();
 
    if (triggerName == "trigger_track_0_a" or triggerName == "trigger_track_0_e")
    {
      int direction = vehicle.GetRelationToTrack(me, "track_0");
      if (!vehicleToTrain)
              direction = -direction;
  
      if (direction == Vehicle.DIRECTION_BACKWARD and triggerName == "trigger_track_0_e")
        return true;
   
      if (direction == Vehicle.DIRECTION_FORWARD and triggerName == "trigger_track_0_a")
        return true;
     }
  
    if (triggerName == "trigger_track_0_a" or triggerName == "trigger_track_0_b" or triggerName == "trigger_track_0_c" or triggerName == "trigger_track_0_d" or triggerName == "trigger_track_0_e")
    {
      if (vehicle.GetMyTrain().IsStopped())
        return true;
    }
 
    return false;
  }
 
 
   void GetTrackAndSide(Vehicle vehicle, string triggerName, TrackLoadInfo retInfo)
    {
    if (triggerName == "trigger_track_0_a" or triggerName == "trigger_track_0_b" or triggerName == "trigger_track_0_c" or triggerName == "trigger_track_0_d" or triggerName == "trigger_track_0_e")
    {
      retInfo.trackName = "track_0";
			retInfo.trainLeftSide = ((vehicle.GetRelationToTrack(me, retInfo.trackName) != Vehicle.DIRECTION_FORWARD) == vehicle.GetDirectionRelativeToTrain());
			retInfo.platformIndex = 0;
    }
 }
 
 
   public void Init(void)
   {
     inherited();
 		
        InitPassengerStation(1);
    		
     StationMain();
   }
  
  
   public void AppendDriverDestinations(string[] destNames, string[] destTracks)
   {
     StringTable stringTable = GetAsset().GetStringTable();
  
     destNames[destNames.size()] = stringTable.GetString("brickstation_platform1");
     destTracks[destTracks.size()] = "track_0";
   }
  	
};
Check compiled for TS12 using "TrainzUtil.exe" for TS12.


Return to HowTo/Build Passenger Enabled Assets
Personal tools