Class InterlockingTower

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m (Add standard API hierarchy)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
 
The InterlockingTower class is the script representation of an in game Interlocking Tower (aka Signal Tower). Interlocking Towers are used to define track "paths" that trains can travel down.
 
The InterlockingTower class is the script representation of an in game Interlocking Tower (aka Signal Tower). Interlocking Towers are used to define track "paths" that trains can travel down.
  
*[[TrainzScript Language Reference|API Hierarchy]]
+
*[[TrainzScript Library Reference|API Hierarchy]]
 
**[[Class GSObject|GSObject]] *
 
**[[Class GSObject|GSObject]] *
 
***[[Class GameObject|GameObject]]
 
***[[Class GameObject|GameObject]]
 
****[[Class TrainzGameObject|TrainzGameObject]]
 
****[[Class TrainzGameObject|TrainzGameObject]]
****[[Class PropertyObject|PropertyObject]] *
 
 
*****[[Class MeshObject|MeshObject]]
 
*****[[Class MeshObject|MeshObject]]
 +
*****[[Class PropertyObject|PropertyObject]] *
 
******[[Class MapObject|MapObject]]
 
******[[Class MapObject|MapObject]]
 
*******InterlockingTower
 
*******InterlockingTower
<br>
 
 
  
 
==Related Classes==
 
==Related Classes==
Line 28: Line 26:
 
Creates a new blank path for use by this tower. Any script which needs to create a path should call this function. Any tower which needs to customise the class can then just override this to create their type.
 
Creates a new blank path for use by this tower. Any script which needs to create a path should call this function. Any tower which needs to customise the class can then just override this to create their type.
 
;Returns
 
;Returns
*A newly created and initialised [[InterlockingTowerPath]] object.
+
*InterlockingTowerPath - A newly created and initialised [[InterlockingTowerPath]] object.
  
 
<br>{{MethodHeader|public string[] GetLocalisedPathNames()}}
 
<br>{{MethodHeader|public string[] GetLocalisedPathNames()}}
Line 34: Line 32:
 
Returns a list of the current (localised) path names.
 
Returns a list of the current (localised) path names.
 
;Returns
 
;Returns
*A string array, containing the localised names of every path.
+
*string[] - A string array, containing the localised names of every path.
  
 
<br>{{MethodHeader|public InterlockingTowerPath FindPathByName(string pathName)}}
 
<br>{{MethodHeader|public InterlockingTowerPath FindPathByName(string pathName)}}
 
;Description
 
;Description
 +
Finds and returns an interlocking path by name, or localised name (for the current language).
 
;Parameters
 
;Parameters
 +
*pathName - The name (or localised name) of the path to find.
 
;Returns
 
;Returns
 +
*InterlockingTowerPath - The found [[InterlockingTowerPath]], or null if no match was found.
 +
  
 
<br>{{MethodHeader|public InterlockingTowerPath[] GetConflictingPaths(InterlockingTowerPath path)}}
 
<br>{{MethodHeader|public InterlockingTowerPath[] GetConflictingPaths(InterlockingTowerPath path)}}
 
;Description
 
;Description
 +
Builds an array of tower paths which have conflicts with the path passed. This will include any other path which shares an object in its path definition or external requirements.
 
;Parameters
 
;Parameters
 +
*path - The [[InterlockingTowerPath]] to examine and find conflicts for.
 
;Returns
 
;Returns
 +
*InterlockingTowerPath[] - An array of tower paths which conflict with the path passed. If no conflicts are found this will be an empty array (i.e. not null).
  
 
<br>{{MethodHeader|public mandatory void SetAIState(int aiState)}}
 
<br>{{MethodHeader|public mandatory void SetAIState(int aiState)}}
 
;Description
 
;Description
 +
Alters the current state of the towers automatic path selection processing.
 
;Parameters
 
;Parameters
;Returns
+
*aiState - The new AI state for the tower, see PATH_ASSIGNMENT_* defines.
 +
;Note
 +
This function is 'mandatory', meaning that any overriding function must call the inherited() in order to compile.
  
 
<br>{{MethodHeader|public void AssignPathToTrain(Train train, string pathName)}}
 
<br>{{MethodHeader|public void AssignPathToTrain(Train train, string pathName)}}
 
;Description
 
;Description
 +
Requests a specific path for the specified train. This will create a queue entry for the train if one doesn't already exist, set it's state to queued and set the path to that requested. The path may not be prepared immediately, if there are conflicting queued entries.
 
;Parameters
 
;Parameters
;Returns
+
*train - The train to assign the path to.
 +
*pathName - The name of the path to assign.
  
 
<br>{{MethodHeader|public void CancelPathForTrain(Train train, string pathName)}}
 
<br>{{MethodHeader|public void CancelPathForTrain(Train train, string pathName)}}
 
;Description
 
;Description
 +
Cancels a specific path for the train passed. If the train is not known, or there is no InterlockingTrainPath entry for this train and signal, then no action will be taken.
 
;Parameters
 
;Parameters
;Returns
+
*train - The train to cancel the path for.
 +
*pathName - The name of the path to cancel.
  
 
<br>{{MethodHeader|public void SetPanicStateForPath(string pathName)}}
 
<br>{{MethodHeader|public void SetPanicStateForPath(string pathName)}}
 
;Description
 
;Description
 +
Sets as specific path to a panic state, dropping all signals immediately, regardless of any occupying or approaching trains.
 
;Parameters
 
;Parameters
;Returns
+
*pathName - The name of the path to set to a panic/emergency state.
  
 
<br>{{MethodHeader|public void SetTrainAsPassing(Train train, Signal entrySignal)}}
 
<br>{{MethodHeader|public void SetTrainAsPassing(Train train, Signal entrySignal)}}
 
;Description
 
;Description
 +
Sets a train's state for a specific entry signal to STATE_PASSING, so the tower knows the train is not entering the interlocking, and will ignore it until it leaves the area. If the train is not known, or there is no InterlockingTrainPath entry for this train and signal, then no action will be taken.
 
;Parameters
 
;Parameters
;Returns
+
*train - The train to set as passing.
 +
*entrySignal - The path entry signal that the train is passing.

Latest revision as of 23:51, 28 December 2020

The InterlockingTower class is the script representation of an in game Interlocking Tower (aka Signal Tower). Interlocking Towers are used to define track "paths" that trains can travel down.

[edit] Related Classes


[edit] Common functions

Below is a list of some of the basic common functions on the InterlockingTower script class. This list is not intended to be comprehensive, merely provide an overview.


public InterlockingTowerPath CreateNewPath()
Description

Creates a new blank path for use by this tower. Any script which needs to create a path should call this function. Any tower which needs to customise the class can then just override this to create their type.

Returns

public string[] GetLocalisedPathNames()
Description

Returns a list of the current (localised) path names.

Returns
  • string[] - A string array, containing the localised names of every path.

public InterlockingTowerPath FindPathByName(string pathName)
Description

Finds and returns an interlocking path by name, or localised name (for the current language).

Parameters
  • pathName - The name (or localised name) of the path to find.
Returns



public InterlockingTowerPath[] GetConflictingPaths(InterlockingTowerPath path)
Description

Builds an array of tower paths which have conflicts with the path passed. This will include any other path which shares an object in its path definition or external requirements.

Parameters
Returns
  • InterlockingTowerPath[] - An array of tower paths which conflict with the path passed. If no conflicts are found this will be an empty array (i.e. not null).

public mandatory void SetAIState(int aiState)
Description

Alters the current state of the towers automatic path selection processing.

Parameters
  • aiState - The new AI state for the tower, see PATH_ASSIGNMENT_* defines.
Note

This function is 'mandatory', meaning that any overriding function must call the inherited() in order to compile.


public void AssignPathToTrain(Train train, string pathName)
Description

Requests a specific path for the specified train. This will create a queue entry for the train if one doesn't already exist, set it's state to queued and set the path to that requested. The path may not be prepared immediately, if there are conflicting queued entries.

Parameters
  • train - The train to assign the path to.
  • pathName - The name of the path to assign.

public void CancelPathForTrain(Train train, string pathName)
Description

Cancels a specific path for the train passed. If the train is not known, or there is no InterlockingTrainPath entry for this train and signal, then no action will be taken.

Parameters
  • train - The train to cancel the path for.
  • pathName - The name of the path to cancel.

public void SetPanicStateForPath(string pathName)
Description

Sets as specific path to a panic state, dropping all signals immediately, regardless of any occupying or approaching trains.

Parameters
  • pathName - The name of the path to set to a panic/emergency state.

public void SetTrainAsPassing(Train train, Signal entrySignal)
Description

Sets a train's state for a specific entry signal to STATE_PASSING, so the tower knows the train is not entering the interlocking, and will ignore it until it leaves the area. If the train is not known, or there is no InterlockingTrainPath entry for this train and signal, then no action will be taken.

Parameters
  • train - The train to set as passing.
  • entrySignal - The path entry signal that the train is passing.
Personal tools