Class Crossing

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m (Change link to library reference, not language reference)
(SetCrossingAutomatic)
Line 86: Line 86:
  
 
===SetCrossingAutomatic===
 
===SetCrossingAutomatic===
{{MethodHeader|public native void SetCrossingAutomatic(bool auto)}}
+
{{MethodHeader|public native void SetCrossingAutomatic(SecurityToken, bool auto)}}
 
;Parameters
 
;Parameters
 
*'''auto''' = True to select automatic mode, false to allow a script to take over.
 
*'''auto''' = True to select automatic mode, false to allow a script to take over.
Line 92: Line 92:
 
*None
 
*None
 
;Syntax
 
;Syntax
  MyCrossing.SetCrossingAutomatic(false);
+
  MyCrossing.SetCrossingAutomatic(token, false);
 
;Notes
 
;Notes
 +
If you do not include the SecurityToken, the call will be flagged obsolete
 
<br>
 
<br>
  

Revision as of 15:55, 24 August 2022


  • An interface to operate a level crossing or similar object.
  • By default a crossing is automatically controlled by trains.
  • When a train is within 200 meters of the crossing, it will be closed and road traffic will not cross the the track.
  • The crossing will reopen for traffic when there are no trains within 200 meters.
  • This class allows a crossing asset with custom scripted behavior to be created so the default behavior described above can be disabled and a script can take control.


Contents

Constants & Messages


Crossing States


  • These values define the current state of the crossing.
  • Note that values 1 and 3 are transient and will occur if the crossing is interrogated in the act of opening or closing.
public define int CROSSING_STATE_OPEN = 0 Crossing is open to road traffic.
public define int CROSSING_STATE_CLOSING = 1 Crossing is in the act of closing.
public define int CROSSING_STATE_CLOSED = 2 Crossing is closed to road traffic.
public define int CROSSING_STATE_OPENING = 3 Crossing is in the act of opening.


Related Messages


  • Messages sent to and from Crossings objects are listed below:
  • Note that these are only a subset of the messages exchanged by the parent SceneryWithTrack class.


Major Minor Source Destination
Object Enter Crossing Crossing
Object Leave Crossing Crossing


Methods

GetCrossingAutomatic

public native bool GetCrossingAutomatic(void)
Parameters
  • None
Returned Value
  • True if crossing is operating in default automatic mode, false if under script control.
Syntax
bool Auto = MyCrossing.GetCrossingAutomatic();
Notes


GetCrossingHasNearbyTrain

public native bool GetCrossingHasNearbyTrain(void)
Parameters
  • None
Returned Value
  • True if any trains are found within the 200 metre trigger radius, false otherwise.
Syntax
bool TrainPresent = MyCrossing.GetCrossingHasNearbyTrain();
Notes


GetCrossingState

public native int GetCrossingState(void)
Parameters
  • None
Returned Value
  • One of the crossing state constants indicating the current condition of the crossing.
Syntax
int State = MyCrossing.GetCrossingState();
Notes
  • If the crossing is in automatic mode the returned state is only valid at the time of the call and can change without script intervention.


SetCrossingAutomatic

public native void SetCrossingAutomatic(SecurityToken, bool auto)
Parameters
  • auto = True to select automatic mode, false to allow a script to take over.
Returned Value
  • None
Syntax
MyCrossing.SetCrossingAutomatic(token, false);
Notes

If you do not include the SecurityToken, the call will be flagged obsolete

SetCrossingState

public native void SetCrossingState(int state)
Parameters
  • state = One of the crossing state constants indicating which state to set.
Returned Value
  • None
Syntax
MyCrossing.SetCrossingState(Crossing.CROSSING_STATE_CLOSED);
Notes
  • Allows the crossing to be opened or closed by a script call.
  • Before using this method you should call SetCrossingAutomatic(false);


Categories

Personal tools