Class JunctionBase
From TrainzOnline
(Difference between revisions)
(→GetMapObject) |
m (1 revision) |
Revision as of 23:58, 3 February 2010
- API Hierarchy
- GSObject *
- GameObject
- TrainzGameObject
- PropertyObject *
- MeshObject
- MapObject
- JunctionBase *
- MapObject
- MeshObject
- GameObject
- GSObject *
- Interface methods to control and obtain information about the status of Junction objects.
- This class relates equally to switch levers controlling spline track junctions and to the junction nodes attached to Fixed Track Junction objects.
Contents |
Constants & Messages
Junction States
- These values define the directions possible through a junction object.
public define int DIRECTION_LEFT = 0 | Left junction direction. |
public define int DIRECTION_FORWARD = 1 | Forward junction direction (straight on for three way points). |
public define int DIRECTION_RIGHT = 2 | Right junction direction. |
public define int DIRECTION_BACKWARD = -1 | Backward junction direction (leading approach). |
public define int DIRECTION_NONE = 3 | No junction direction or error condition. |
Related Messages
- Messages sent to and from Junction objects are listed below:
Major | Minor | Source | Destination |
Junction | Toggled | Junction | Broadcast |
Junction | Enter | Junction | Train |
Junction | InnerEnter | Junction | Train |
Junction | Stopped | Junction | Train |
Junction | InnerLeave | Junction | Train |
Junction | Leave | Junction | Train |
Object | Enter | Train | Junction |
Object | InnerEnter | Train | Junction |
Object | Stopped | Train | Junction |
Object | InnerLeave | Train | Junction |
Object | Leave | Train | Junction |
Methods
AllowManualControl
public native voidAllowManualControl(bool allow)
- Parameters
- allow = True to allow the user to toggle the junction, false otherwise.
- Returned Value
- None
- Syntax;
AllowManualControl(true);
- Notes
GetDebugString
public string GetDebugString(void)
- Parameters
- None
- Returned Value
- A string that contains the node ID and name of the MapObject associated with this junction. If successful, the returned string will include the node ID and name of the MapObject. Otherwise an error string will be returned instead.
- Syntax;
Interface.Print(GetDebugString());
- Notes
GetDirection
public native int GetDirection(void)
- Parameters
- None
- Returned Value
- One of the Junction State constants indicating the current direction of the junction.
- Syntax;
int direction = GetDirection();
- Notes
GetDirectionToTrain
public native int GetDirectionToTrain(Train train)
- Parameters
- train = A reference to a train located within 15 track stretches of the junction.
- Returned Value
- One of the Junction State constants indicating the track on which the train was found.
- Syntax;
int approachPath = GetDirectionToTrain(train);
- Notes
- DIRECTION_NONE is returned if the train is not within range.
GetGameObject
public native GameObject GetGameObject(void)
- Parameters
- None
- Returned Value
- A reference to the GameObject associated with this junction.
- Syntax;
GameObject go = junction.GetGameObject();
- Notes
- For a trackside spline junction this method returns the junction lever object.
- For an embedded junction in a fixed track junction the object returned is the embedded junction node.
- In either case null is returned on failure.
GetManualControl
public native bool GetManualControl(void)
- Parameters
- None
- Returned Value
- True if the user is allowed to toggle this junction, false otherwise.
- Syntax;
bool locked = !GetManualControl();
- Notes
GetMapObject
public native MapObject GetMapObject(void)
- Parameters
- None
- Returned Value
- A reference to the MapObject associated with this junction.
- Syntax;
MapObject mo = junction.GetMapObject();
- Notes
- For a trackside spline junction this method returns the junction lever object.
- For an embedded junction in a fixed track piece the object returned is the fixed track parent object.
- In either case null is returned on failure.
JunctionInnerReEnter
public native bool JunctionInnerReEnter(int node)
- Parameters
- node = Node Id of train as returned by Train.GetId().
- Returned Value
- None
- Syntax;
junction.JunctionInnerReEnter(train);
- Notes
- The effect of this method is to cause a new Junction,InnerEnter message to be sent to the Junction if any part of the train is within the inner trigger radius.
JunctionReEnter
public native bool JunctionReEnter(int node)
- Parameters
- node = Node Id of train as returned by Train.GetId().
- Returned Value
- None
- Syntax;
junction.JunctionReEnter(train);
- Notes
- The effect of this method is to cause a new Junction,Enter message to be sent to the Junction if any part of the train is within the default outer trigger radius.
RequestPermit
public native Permit RequestPermit(GameObject obj)
- Parameters
- obj = Object requesting the Permit.
- Returned Value
- Returns a Permit for obj to control the junction.
- Syntax;
Permit permit = RequestPermit(train);
- Notes
- Although a Permit is always returned, it may not necessarily be granted.
RequestTrackPermit
public native Permit RequestTrackPermit(GameObject obj, int direction)
- Parameters
- obj = Object requesting the Permit.
- direction = One of the Junction State constants indicating the direction of the track relative to the current junction.
- Returned Value
- Returns a Permit for obj to control the specified track.
- Syntax;
Permit permit = RequestTrackPermit(train, DIRECTION_LEFT);
- Notes
- Although a Permit is always returned, it may not necessarily be granted.
SetDirection
public native bool SetDirection (int direction)
- Parameters
- direction = New direction to set.
- Returned Value
- True if the junction is changed, False if the direction is unchanged or if the specified direction was invalid for this junction.
- Syntax;
if (junction.SetDirection(DIRECTION_LEFT)) Interface.Print("Junction now set to the left");
- Notes
- This method switches the junction unconditionally, disregarding any Permits that may exist.
SwitchForTrain
public native bool SwitchForTrain(Train train, int direction)
- Parameters
- train = Train that is to pass over the junction.
- direction = One of the Junction State constants indicating the current position of the train relative junction.
- Returned Value
- True if the junction is changed, False if the direction is unchanged or if the specified direction was invalid for this junction.
- Syntax;
junction.SwitchForTrain(train,DIRECTION_BACKWARD);
- Notes
- The new direction must be on the opposite side of the junction to the train's current position.
- This method switches the junction unconditionally, disregarding any Permits that may exist.
Related Methods
SceneryWithTrack.GetAttachedJunctions()
World.GetJunctionList()