Class SceneryWithTrack

From TrainzOnline
Revision as of 23:58, 3 February 2010 by Windwalkr (Talk | contribs)

Jump to: navigation, search


  • Parent class for scenery objects that have attached track and attached trigger support, such as industries and crossings.
  • Where triggers are covered within this document these are attached scenery triggers, as defined in the asset's attached-trigger table, and should not be confused with Trackside Triggers.
  • Attached scenery triggers and their attributes (name, radius, track) are defined as part of the asset's configuration and cannot be altered or moved in Surveyor.


Contents

Related Messages

  • Messages sent to and from SceneryWithTrack objects are listed below:


Major Minor Source Destination
SceneryTrigger Enter SceneryWithTrack Vehicle
SceneryTrigger InnerEnter SceneryWithTrack Vehicle
SceneryTrigger Stopped SceneryWithTrack Vehicle
SceneryTrigger InnerLeave SceneryWithTrack Vehicle
SceneryTrigger Leave SceneryWithTrack Vehicle
Object Enter Vehicle SceneryWithTrack
Object InnerEnter Vehicle SceneryWithTrack
Object Stopped Vehicle SceneryWithTrack
Object InnerLeave Vehicle SceneryWithTrack
Object Leave Vehicle SceneryWithTrack


  • Embedded JunctionBase objects issue their own messages in addition to those sent to and from the parent SceneryWithTrack object.


FindTriggerContainingNode

public native string FindTriggerContainingNode(int node, bool onlyInner)
Parameters
  • node = The GameObject Id of a vehicle, usually obtained by a call to GetId ().
  • onlyInner = If true only the inner radius of the trigger will be tested, if false the the trigger name will be returned if the vehicle is within 150 metres of the trigger. which trigger is returned if more than one meets this test?
Returned Value
  • The name of the scenery trigger found, an empty string otherwise.
Syntax
string trigger = FindTriggerContainingNode(vehicle.GetId(),true);
Notes
  • This method returns the name of the attached scenery trigger within which the specified vehicle is currently located.


GetAttachedJunctions

public native JunctionBase[ ] GetAttachedJunctions(void)
Parameters
  • None
Returned Value
  • An array of any attached JunctionBase objects included within this object, null if there are no such attachments.
Syntax
JunctionBase[] nodes = GetAttachedJunctions();
Notes
  • JunctionBase arrays are only returned for objects set up as fixed track junctions.
  • The array contains the JunctionBases listed in the junction-vertices container in config.txt.
  • The size of the array and the ordering of the individual components will match the number and sequence of the subcontainers within the junction-vertices table.


GetAttachedTrack

public native Track GetAttachedTrack(string trackName)
Parameters
  • trackName = The named track section as defined in the attached-track table in config.txt.
Returned Value
  • A reference to a Track object if it exists, a script exception will occur otherwise.

Wouldn't null be more polite than an exception?

Syntax
Track track = GetAttachedTrack("track01");
Notes


GetTriggerTrack

public native Track GetTriggerTrack(string triggerName)
Parameters
  • triggerName = A trigger name as defined in the attached-trigger container in config.txt.
Returned Value
  • A reference to a Track object if it exists, a script exception will occur otherwise.

Wouldn't null be more polite than an exception?

Syntax
Track track = GetTriggerTrack("trigger01");
Notes
  • The track returned is as sepcified in the track tag of the attached-trigger table in config.txt.


InnerReEnter

public native bool InnerReEnter(int node)
Parameters
  • node = Node Id of a vehicle to be re-entered into inner trigger radius.
Returned Value
  • True if the vehicle is within the inner trigger radius and the message has been sent, false otherwise.
Syntax
InnerReEnter(vehicle.GetId());
Notes
  • The effect of this method is to cause a new Object,InnerEnter message to be sent from the vehicle to the SceneryWithTrack object.


InnerReEnterTrain

public void InnerReEnterTrain(Train train)
Parameters
  • train = A train reference, InnerReEnter will be called on all the vehicles in the train.
Returned Value
  • None
Syntax
InnerReEnterTrain(train);
Notes
  • Messages are only issued in respect of vehicles actually within the inner trigger at the time of the call?


IsTrainInTriggers

public native bool IsTrainInTriggers(Train train, bool onlyInner
Parameters
  • train = A reference to the train to look for.
  • onlyInner = If true only the inner radius of the trigger will be tested, if false the the radius tested will be the default 150 metres.
Returned Value
  • True if any part of the specified train is within the trigger radius, false otherwise.
Syntax
bool trainFound = IsTrainInTriggers(train,true);
Notes


ReEnter

public native bool ReEnter(int node)
Parameters
  • node = Node Id of a vehicle to be re-entered into default 150 metre trigger radius.
Returned Value
  • True if the vehicle is within the 150 metre trigger radius and the message has been sent, false otherwise.
Syntax
ReEnter(vehicle.GetId());
Notes
  • The effect of this method is to cause a new Object,Enter message to be sent from the vehicle to the SceneryWithTrack object.


Code Examples


Related Methods

Industry.HasTrack()

JunctionBase.GetMapObject()


Categories

Personal tools