Class Locomotive

From TrainzOnline
Jump to: navigation, search


  • A Locomotive is a specialised instance of a vehicle.
  • In practice many of the methods in Class Vehicle apply to powered vehicles.
  • A locomotive is always part of a train, if a locomotive is decoupled and left alone TRS will create a new consist to include it.


Contents

Methods


GetCabinData

public CabinData GetCabinData(void)
Parameters
  • None
Returned Value
  • A reference to a data object which stores the state of the locomotive's cabin.
Syntax
MyCabinData = loco.GetCabinData();
Notes
  • See Class CabinData
  • The data object refers to an internal private CabinData object in this class that represents the state of the cabin's controls.
  • This is usually maintained by the Cabin.Attach() and Cabin.Update() methods of the Cabin script.


GetEngineSetting

public native float GetEngineSetting(string setting)
Parameters
  • setting = The name of the setting to retrieve.
Returned Value
  • The value of the named setting.
Syntax
float throttle = GetEngineSetting("throttle");
Notes
  • See SetEngineSetting() for details of the values which can be used for the setting parameter.


SetBellState

public native void SetBellState(bool state)
Parameters
  • state = If true plays and loops the sound of a bell, a value of false will deactivation it.
Returned Value
  • None
Syntax
SetBellState(true);
Notes
  • Asset of kind "hornsound" must be in the locomotive config.


SetBrokenReverser

public native void SetBrokenReverser(bool broken)
Parameters
  • broken = If true the reverser will not function, a value of false will reactivate it.
Returned Value
  • None
Syntax
SetBrokenReverser(true); 
Notes
  • When broken the reverser lever can still be used by the player but it will have no effect on the locomotive.


SetBrokenThrottle

public native void SetBrokenThrottle(bool broken)
Parameters
  • broken = If true the throttle will not function, a value of false will reactivate it.
Returned Value
  • None
Syntax
SetBrokenThrottle(true);
Notes
  • When broken the throttle lever can still be used by the player but it will have no effect on the locomotive.


SetCabinData

public void SetCabinData(CabinData data)
Parameters
  • data = A reference to the data object used to store details of the locomotive's cabin controls.
Returned Value
  • None
Syntax
SetCabinData(MyCabinData);
Notes
  • See Class CabinData
  • The data object refers to an internal private CabinData object in this class that represents the state of the cabin's controls.
  • This is usually maintained by the Cabin.Attach() and Cabin.Update() methods of the Cabin script.


SetCompressorEfficiency

public native void SetCompressorEfficiency(float efficiency)
Parameters
  • efficiency = Efficiency of the compressor in the range 0.0 .. 1.0
Returned Value
  • None
Syntax
SetCompressorEfficiency(0.5);
Notes
  • For a slow increase in pressure of the main reservoir.


SetEngineSetting

public native void SetEngineSetting(string setting, float value)
Parameters
  • setting = The name of the setting to save.
  • value = The value of the named setting.
Returned Value
  • None
Syntax
SetEngineSetting("regulator",0.5);
Notes
  • Settings you can write to with this method are:
    • "dynamic-brake"
    • "headlight" (value 0,0.5,1 only)
    • "horn"
    • "injector"
    • "loco-auto-brake" (i.e independantbrake_lever)
    • "pantograph"
    • "regulator"
    • "reverser"
    • "steam-blower"
    • "throttle"
    • "train-auto-brake" (i.e. trainbrake_lever')
    • "train-lap-brake"
    • "script-brake-pressure" - A script-only brake pressure which does not correspond to any real brake device, specified in kPa. This may be used by interior scripts for implementing custom cab-mode braking behaviour, and is intended to be directly mapped from the cab controls rather than updated on a regular frame-by-frame basis from script. Native brake controls should be used where possible to avoid significant performance problems.
  • Some apply to steam locomotives only.
  • From personal experience: the settings for the electric locomotive are set in whole numbers ("dynamic-brake" 0-1-2; "reverser" 0-1-2 and so on).


SetHasDriver

public native void SetHasDriver(bool hasDriver)
Parameters
  • hasDriver = If true the locomotive has an assigned driver, if false it does not.
Returned Value
  • None
Syntax
SetHasDriver(true);
Notes
  • Only one locomotive in a train may have a driver.
  • If you attempt to place a driver in this loco, any other driver on the train will be removed.
  • The consist name and id will always stay with the driver.


Code Examples


Related Methods

Train.GetFrontmostLocomotive()
Train.GetVehicles()
World.GetVehicleList()

Categories

Personal tools