Class Locomotive

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
m (1 revision)
m
Line 1: Line 1:
*[[TrainzScript Langage Reference|API Hierarchy]]
+
*[[TrainzScript Language Reference|API Hierarchy]]
 
**[[Class GSObject|GSObject]] *
 
**[[Class GSObject|GSObject]] *
 
***[[Class GameObject|GameObject]]
 
***[[Class GameObject|GameObject]]

Revision as of 02:21, 10 February 2010


  • 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.


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(ture); 
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


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"
    • "injector"
    • "loco-auto-brake"
    • "pantograph"
    • "regulator"
    • "reverser"
    • "steam-blower"
    • "throttle"
    • "train-auto-brake"
    • "train-lap-brake"
  • These strings correspond to engine properties as described in the Content Creation Guide.
  • Some apply to steam locomotives only.


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