Class Vehicle
From TrainzOnline
- A vehicle is a single piece of rolling stock including locomotives and tenders.
- A vehicle is always part of a train, if a vehicle is decoupled and left alone TRS will create a new consist to include it.
Related Messages
- Messages sent to and from Vehicle objects are listed below:
Major | Minor | Source | Destination | |
Vehicle | Derailed | Vehicle | Broadcast | Vehicle has derailed and can no longer be used. |
Vehicle | Coupled | Vehicle | Broadcast | Vehicle has coupled up with another vehicle. |
Vehicle | Decoupled | Vehicle | Broadcast | Vehicle has decoupled from another vehicle. |
Vehicle | Bad Couple | Vehicle | Broadcast | Vehicle has coupled with another vehicle at too high a velocity. |
Vehicle | Collided | Vehicle | Broadcast | Vehicle has collided with another vehicle. |
Constants
Coupler Flags
public define int COUPLE_NONE = 0 | Neither coupler. |
public define int COUPLE_FRONT = 1 | Front coupler. |
public define int COUPLE_BACK = 2 | Back coupler. |
public define int COUPLE_BOTH = COUPLE_FRONT ¦ COUPLE_BACK | Both couplers. |
Direction Relationships
public define int DIRECTION_NONE = 0 | No known relationship. |
public define int DIRECTION_FORWARD = 1 | Forward, facing in the same direction. |
public define int DIRECTION_BACKWARD = -1 | Backward, facing in opposite directions. |
Engine Types
public define int ENGINE_NONE = 0 | Not a powered vehicle. |
public define int ENGINE_STANDARD = 1 | Diesel, Diesel-Electric, Electric. |
public define int ENGINE_STEAM = 2 | Steam powered. |
Vehicle Type Flags
public define int TYPE_LOCOMOTIVE = 1 | Vehicle is a powered locomotive. |
public define int TYPE_TENDER = 2 | Vehicle carries fuel for a locomotive. |
public define int TYPE_HAS_INTERIOR = 4 | Vehicle has an interior. This does not necessarily mean that it is a lcomotive. |
Members
public IndustryProductInfoCollection vehicleProductInfoCollection | A data object that allows tracking of products and associated assets & queues. |
Methods
BeginLoad
float BeginLoad(LoadingReport report)
- Parameters
- report = Report on the current state of the loading operation.
- Returned Value
- The time required, in seconds, for the activity to complete.
- Syntax
float BeginLoad(LoadingReport report) { DoStuff(report); return 10.0; }
- Notes
- This is a callback method which should be overridden by the script writer to perform customised activities before loading at an industry.
- These include such operations as particle effects and animations.
- The report parameter provides details of the industries and vehicles involved and of their spatial relationship.
- It is the responsibility of the script writer to determine the time required for these activities and to return this in the method result.
BeginUnload
float BeginUnload(LoadingReport report)
- Parameters
- report = Report on the current state of the loading operation.
- Returned Value
- The time required, in seconds, for the activity to complete.
- Syntax
float BeginLoad(LoadingReport report) { DoStuff(report); return 10.0; }
- Notes
- This is a callback method which should be overridden by the script writer to perform customised activities before loading at an industry.
- These include such operations as particle effects and animations.
- The report parameter provides details of the industries and vehicles involved and of their spatial relationship.
- It is the responsibility of the script writer to determine the time required for these activities and to return this in the method result.
CanLoadProductFromQueue
public bool CanLoadProductFromQueue(ProductQueue queue)
- Parameters
- queue = The queue to be queried.
- Returned Value
- True if the vehicle and queue are compatible and the queue can be used to load the vehicle, false otherwise.
- None
- Syntax
if (CanLoadProductFromQueue(industryOutQueue)) { DoTheProcess(); }
- Notes
CanUnloadProductToQueue
public bool CanUnloadProductToQueue(ProductQueue queue)
- Parameters
- queue = The queue to be queried.
- Returned Value
- True if the vehicle and queue are compatible and the queue can be used to unload the vehicle, false otherwise.
- Syntax
if (CanUnloadProductToQueue(industryOutQueue)) { DoTheProcess(); }
- Notes
Couple
public native bool Couple(Vehicle other)
- Parameters
- other' = Adjacent vehicle to couple to.
- Returned Value
- True if the operation was successfully completed, fale otherwise.
- Syntax
if (Couple(vehicle2)) Interface.Print("Success!");
- Notes
- Couples this vehicle to the given vehicle which must already be adjacent.
- When a vehicle is decoupled from another, the couplers are left in an unlocked state, even though the vehicles are flush against each other.
- This state will remain until the vehicles move a small distance apart.
- Sometimes you may wish to cause them to couple again and that is the intended use of this method.
- If the two vehicles involved are not adjacent then this method will have no effect.
EndLoad
float EndLoad(LoadingReport report)
- Parameters
- report = Report on the current state of the loading operation.
- Returned Value
- The time required, in seconds, for the activity to complete.
- Syntax
float EndLoad(LoadingReport report) { DoStuff(report); return 10.0; }
- Notes
- This is a callback method which should be overridden by the script writer to perform customised activities after loading at an industry.
- These include such operations as particle effects and animations.
- The report parameter provides details of the industries and vehicles involved and of their spatial relationship.
- It is the responsibility of the script writer to determine the time required for these activities and to return this in the method result.
EndUnload
float EndUnload(LoadingReport report)
- Parameters
- report = Report on the current state of the loading operation.
- Returned Value
- The time required, in seconds, for the activity to complete.
- Syntax
float EndUnload(LoadingReport report) { DoStuff(report); return 10.0; }
- Notes
- This is a callback method which should be overridden by the script writer to perform customised activities after unloading at an industry.
- These include such operations as particle effects and animations.
- The report parameter provides details of the industries and vehicles involved and of their spatial relationship.
- It is the responsibility of the script writer to determine the time required for these activities and to return this in the method result.
GetAuxReservoirPressure
public native float GetAuxReservoirPressure(void)
- Parameters
- None
- Returned Value
- The current auxiliary reservoir pressure of this vehicle.
- Syntax
float ARP = GetAuxReservoirPressure();
- Notes
GetBogeyList
public native Bogey[ ] GetBogeyList(void)
- Parameters
- None
- Returned Value
- An array containing references to all the Bogey objects attached to this vehicle.
- Syntax
Bogey[] bogies = GetBogeyList();
- Notes
- Bogies are indexed in the same numerical order as they are listed in config.txt.
- Invisible bogies etc. are included.
GetBrakeCylinderPressure
public native float GetBrakeCylinderPressure(void)
- Parameters
- None
- Returned Value
- The current brake cylinder pressure of this vehicle.
- Syntax
float BCP = GetBrakeCylinderPressure();
- Notes
GetBrakePipePressure
public native float GetBrakePipePressure(void)
- Parameters
- None
- Returned Value
- The current brake pipe pressure of this vehicle.
- Syntax
float BPP = GetBrakePipePressure();
- Notes
GetCabinSwayAmount
public native float GetCabinSwayAmount(void)
- Parameters
- None
- Returned Value
- The cabin sway amount for this vehicle.
- Syntax
float CSA = GetCabinSwayAmount();
- Notes
- Higher positive values indicate higher levels of cabin sway while a 0.0 indicates no cabin sway.
- See also SetCabinSwayAmount().
GetCouplerBreakageEnabled
public native bool GetCouplerBreakageEnabled(void)
- Parameters
- None
- Returned Value
- True if coupler breakages are enabled on this vehicle, false otherwise.
- Syntax
if (GetCouplerBreakageEnabled()) Interface.Print("Drive carefully to avoid breaking the couplers");
- Notes
GetCouplingDirection
public native int GetCouplingDirection(Vehicle other)
- Parameters
- other' = Adjacent vehicle to couple to.
- Returned Value
- One of the Direction Relationship constants indicating the direction of a neighbouring vehicle, relative to the direction of the caller.
- Syntax
bool direction = GetCouplingDirection(vehicle2);
- Notes
- If the result is DIRECTION_FORWARD then both vehicles have the same orientation.
- If the result is DIRECTION_BACKWARD then the two vehicles face in opposite directions.
- The fact that this method returns a value does not mean that it is possible for the two vehicles to couple.
GetCouplingStress
public native float GetCouplingStress(Vehicle other)
- Parameters
- other' = Other vehicle in the same consist to query.
- Returned Value
- The calculated coupling stress between the two vehicles in kilonewtons (kN);
- Syntax
float kn = GetCouplingStress(vehicle2);
- Notes
- <float color=red>Must the two vehicles be adjacent?</font>
GetDefaultCabinSwayAmount
public native float GetDefaultCabinSwayAmount(void)
- Parameters
- None
- Returned Value
- The default cabin sway amount for this vehicle as defined in config.txt.
- Syntax
float CSA = GetCabinSwayAmount();
- Notes
- Higher positive values indicate higher levels of cabin sway while a 0.0 indicates no cabin sway.
- See also SetCabinSwayAmount().
GetDefaultMaximumCouplerCompressionStress
publc native float GetDefaultMaximumCouplerCompressionStress(void)
- Parameters
- None
- Returned Value
- The default maximum coupler expansion stress value for this vehicle in kilonewtons (kN), as defined in config.txt.
- Syntax
float DMCS = GetDefaultMaximumCouplerCompressionStress();
- Notes
GetDefaultMaximumCouplerExpansionStress
public native float GetDefaultMaximumCouplerExpansionStress(void)
- Parameters
- None
- Returned Value
- The default maximum coupler compression stress value for this vehicle in kilonewtons (kN), as defined in config.txt.
- Syntax
float DMCE = GetDefaultMaximumCouplerExpansionStress();
- Notes
GetDefaultMaximumCoupleVelocity
public native float GetDefaultMaximumCoupleVelocity(void)
- Parameters
- None
- Returned Value
- The default maximum speed at which this vehicle can be coupled to without breaking the coupler, as defined in config.txt.
- Syntax
float DMCV = GetDefaultMaximumCoupleVelocity();
- Notes
GetDefaultMaximumTractiveEffort
GetDefaultMaximumTractiveEffort()
- Parameters
- None
- Returned Value
- The default maximum tractive effort of this vehicle from its configuration in kilonewtons (kN), as defined in config.txt.
- Syntax
float DMTE = GetDefaultMaximumTractiveEffort();
- Notes
GetDirectionRelativeToTrain
public native bool GetDirectionRelativeToTrain(void)
- Parameters
- None
- Returned Value
- True if this vehicle faces in the same direction as the train's current heading, false otherwise.
- Syntax
bool vehicleToTrain = GetDirectionRelativeToTrain();
- Notes
GetEngineParam
public native float GetEngineParam(string param)
- Parameters
- param = One of the engine parameter strings listed below.
- Returned Value
- The current value of the given engine parameter.
- Syntax
float pressure = GetEngineParam("steam-boiler-pressure");
- Notes
- Engine parameter strings you can use with this method are:
- "brake-cylinder-pressure"
- "brake-pipe-pressure"
- "coal-mass"
- "current-drawn"
- "equaliser-pressure"
- "fire-temperature"
- "flow"
- "horn"
- "main-reservoir-pressure"
- "max-coal-mass"
- "max-fire-temperature"
- "no3-pipe-pressure"
- "steam-boiler-liquid-percent"
- "steam-boiler-pressure"
- "steam-piston-cycle"
- "wheelslip"
- "engine-force"
- "applied-force"
- "max-te"
- Some of the values refer only to steam engines.
GetEngineType
public native int GetEngineType(void)
- Parameters
- None
- Returned Value
- One of the Engine Type constants describing the engine type of this vehicle.
- Syntax
int eType = GetEngineType();
- Notes
GetLength
public native float GetLength(void)
- Parameters
- None
- Returned Value
- The length of this vehicle in metres.
- Syntax
float length = GetLength();
- Notes
GetLoadTime
float GetLoadTime(LoadingReport report)
- Parameters
- report = Report on the current state of the loading operation.
- Returned Value
- The time required, in seconds, for the activity to complete.
- Syntax
float GetLoadTime(LoadingReport report) { DoStuff(report); return 10.0; }
- Notes
- This is a callback method which informs the game engine of the time needed to load this vehicle.
- The method may be use to perform customised activities during the loading operation.
- These include such operations as particle effects and animations.
- The report parameter provides details of the industries and vehicles involved and of their spatial relationship.
- It is the responsibility of the script writer to determine the time required for these activities and to return this in the method result.
GetMass
public native float GetMass(void)
- Parameters
- None
- Returned Value
- The mass of the vehicle in kilograms.
- Syntax
float mass = GetMass();
- Notes
GetMaximumCouplerCompressionStress
publc native float GetMaximumCouplerCompressionStress(void)
- Parameters
- None
- Returned Value
- The maximum coupler expansion stress value for this vehicle in kilonewtons (kN).
- Syntax
float MCS = GetMaximumCouplerCompressionStress();
- Notes
GetMaximumCouplerExpansionStress
public native float GetMaximumCouplerExpansionStress(void)
- Parameters
- None
- Returned Value
- The maximum coupler expansion stress value for this vehicle in kilonewtons (kN).
- Syntax
float DMCE = GetMaximumCouplerExpansionStress();
- Notes
GetMaximumCoupleVelocity
public native float GetMaximumCoupleVelocity(void)
- Parameters
- None
- Returned Value
- The maximum speed at which this vehicle can be coupled to without breaking the coupler.
- Syntax
float MCV = GetMaximumCoupleVelocity();
- Notes
GetMaximumTractiveEffort
GetMaximumTractiveEffort()
- Parameters
- None
- Returned Value
- The maximum tractive effort of this vehicle from its configuration in newtons (N).
- Syntax
float MTE = GetMaximumTractiveEffort();
- Notes
GetMyTrain
public native Train GetMyTrain(void)
- Parameters
- None
- Returned Value
- A reference to the train of which this vehicle is part.
- Syntax
Train train = GetMyTrain();
- Notes
- All vehicles belong to a Train consist, even if a vehicle is not coupled to any other vehicle.
GetProductRestriction
public ProductFilter GetProductRestriction(void)
- Parameters
- None
- Returned Value
- The current product restriction filter if any, null otherwise.
- Syntax
ProductFilter filter = GetProductRestriction();
- Notes
GetRelationToTrack
public native int GetRelationToTrack(Buildable obj, string trackName)
- Parameters
- obj = Reference to a Buildable object.
- trackName = String representing the name of a track as defined in the Buildable's config.txt.
- Returned Value
- One of the Direction Relationship constants indicating the direction of the vehicle, relative to the Buildable's attached track.
- Syntax
- This method will return either DIRECTION_FORWARD or DIRECTION_BACKWARD if the vehicle is on the track as specified by the arguments or on a directly neighboring track, otherwise DIRECTION_NONE will be returned.
- Notes
GetRunningNumber
public native string GetRunningNumber(void)
- Parameters
- None
- Returned Value
- The running (fleet identification) number of the vehicle.
- Syntax
string fleetId = GetRunningNumber();
- Notes
- This value is set using SetRunningNumber() and should be restricted to alphanumeric characters and paces.
GetSandingTractionMultiplier
public native float GetSandingTractionMultiplier(void)
- Parameters
- None
- Returned Value
- A wheelslip traction multiplier to apply when sand is in use.
- Syntax
float slipFactor = GetSandingTractionMultiplier();
- Notes
- The returned value will be greater than or equal to 1.0.
- See SetSandingTractionMultiplier();
GetTrackGradient
public native float GetTrackGradient(void)
- Parameters
- None
- Returned Value
- The current track gradient as a percentage.
- Syntax
float gradient = GetTrackGradient();
- Notes
- The sign of the gradient is determined by the direction of this vehicle relative to the gradient.
- A negative sign indicates that the vehicle is facing down a gradient while a positive sign indicates the vehicle is facing up a gradient.
- The vehicle's direction may not match that of the train so the value returned here may not be what you expect.
- Use GetDirectionRelativeToTrain() to check this.
GetUnloadTime
float GetUnloadTime(LoadingReport report)
- Parameters
- report = Report on the current state of the loading operation.
- Returned Value
- The time required, in seconds, for the activity to complete.
- Syntax
float GetUnloadTime(LoadingReport report) { DoStuff(report); return 10.0; }
- Notes
- This is a callback method which informs the game engine of the time needed to unload this vehicle.
- The method may be use to perform customised activities during the unloading operation.
- These include such operations as particle effects and animations.
- The report parameter provides details of the industries and vehicles involved and of their spatial relationship.
- It is the responsibility of the script writer to determine the time required for these activities and to return this in the method result.
GetVehicleTypeFlags
public native int GetVehicleTypeFlags(void)
- Parameters
- None
- Returned Value
- One of the Vehicle Type Flags representing what kind of vehicle the current object is.
- Syntax
int flags = GetVehicleTypeFlags();
- Notes
GetVelocity
public native float GetVelocity(void)
- Parameters
- None
- Returned Value
- The current instantaneous velocity of the train in metres per second.
- Syntax
float speed = GetVelocity();
- Notes
- Use the Measurement Conversion Multiplier constants for conversion to other units.
- For human consumption Train.GetSmoothedVelocity() may be preferable.
GetWheelslipTractionMultiplier
public native float GetWheelslipTractionMultiplier(void)
- Parameters
- None
- Returned Value
- The current wheelslip traction multiplier value.
- Syntax
float slip = GetWheelslipTractionMultiplier();
- Notes
- The returned value will be greater than or equal to 1.0.
- See SetWheelslipTractionMultiplier();
IsInTunnel
public native bool IsInTunnel(void)
- Parameters
- None
- Returned Value
- True if this vehicle is in a tunnel, false otherwise.
- Syntax
bool underground = IsInTunnel();
- Notes
IsOnBridge
public native void IsOnBridge(void)
- Parameters
- None
- Returned Value
- True if this vehicle is on a bridge, false otherwise.
- Syntax
bool onBridge = IsOnBridge();
- Notes
LoadProduct
public bool LoadProduct(LoadingReport report)
- Parameters
- report = Report on the current state of the loading operation.
- Returned Value
- True if the loading operation was successful, false otherwise.
- Syntax
LoadProduct(report);
- Notes
- Loads products into this vehicle as defined by the given report.
- This method works by attempting to transfer products to this vehicle's queues if possible from the industry queue specified in report.
- The sequence of events for a loading operation as performed by this method is:
- Verify that an loading operation is possible with this vehicle by calling CanLoadProductFromQueue().
- BeginLoad() on this vehicle and Industry.BeginLoad() on the industry specified in the report are called to perform any pre-loading events like animation or particle effects on the vehicle and industry respectively.
- Both of these methods return the amount of time required for a load operation and the LoadProduct() method sleeps for which ever of these times is the longer.
- The actual product transfer from the industry to the vehicle is performed by calling ProductQueue.TransferProductFrom() on this vehicle's queue(s).
- GetLoadTime() on this vehicle and Industry.GetLoadTime() are called. Again, LoadProduct() sleeps for which ever is the longer of the times returned.
- EndLoad() and Industry.EndLoad() are called to perform any post-loading events. As before LoadProduct() sleeps for the longer time.
Reposition
public native bool Reposition(Train train, int myCoupleDir, int otherCoupleDir)
public native bool Reposition(Vehicle vehicle, int myCoupleDir, int otherCoupleDir)
public native bool Reposition(TrackMark mark, bool direction)
public native bool Reposition(Vehicle vehicle, int myCoupleDir, int otherCoupleDir)
public native bool Reposition(TrackMark mark, bool direction)
- Parameters
- train = Train to attach the vehicle to.
- vehicle = Vehicle to attach the vehicle to.
- myCoupleDir = The end of the current vehicle that will be coupled, use either COUPLE_FRONT or COUPLE_BACK.
- otherCoupleDir = The end of the target vehicle that will be coupled to, use either COUPLE_FRONT or COUPLE_BACK.
- mark = Trackmark to move this vehicle to.
- direction = Direction for the vehicle, relative to the TrackMark.
- None
- Returned Value
- True if the operation was successfully completed, false otherwise.
- Syntax
Reposition(Train3,COUPLE_FRONT,COUPLE_BACK); Reposition(Vehicle5,COUPLE_FRONT,COUPLE_BACK); Reposition(Mark9,true);
- Notes
- Variant 1 moves the current vehicle and couples it to the specified train using the specified vehicle ends.
- Variant 2 moves the current vehicle and couples it to the specified vehicle using the specified vehicle ends.
- Variant 3 moves the current vehicle from its train to the specified trackmark, normally creating a new consist.
Reverse
public native bool Reverse(void)
- Parameters
- None
- Returned Value
- True if the operation was successfully completed, false otherwise.
- Syntax
if (Reverse()) Interface.Print("Direction of " + GetName() + " reversed");
- Notes
- This method reverses the direction of the current vehicle in relation to its consist.
SetBrakePipeEfficiency
public native void SetBrakePipeEfficiency(float efficiency)
- Parameters
- efficiency = A Normalised value in the range 0.0 .. 1.0 representing the efficiency of the brake pipe.
- Returned Value
- None
- Syntax
SetBrakePipeEfficiency(0.5);
- Notes
SetBrokenBrakes
public native void SetBrokenBrakes(bool broken)
- Parameters
- broken = True to render the brakes non operational, false to repair them.
- Returned Value
- None
- Syntax
SetBrokenBrakes(true);
- Notes
SetCabinSwayAmount
public native void SetCabinSwayAmount(float amount)
- Parameters
- amount = Cabin sway value greater than or equal to zero.
- Returned Value
- None
- Syntax
SetCabinSwayAmount(2.5);
- Notes
- A value of zero removes all sway.
- Higher positive values increase the effect.
- The method is only of relevance to vehicles with interior views.
SetCouplerBreakageEnabled
public native void SetCouplerBreakageEnabled(bool enabled)
- Parameters
- enabled = True enables simulation of coupler breakage.
- None
- Returned Value
- None
- Syntax
SetCouplerBreakageEnabled(true);
- Notes
SetCouplingMask
public native void SetCouplingMask(int mask)
- Parameters
- mask = A mask specifying which of the vehilce's couplers are allowed to couple.
- Returned Value
- None
- Syntax
SetCouplingMask(COUPLE_NONE); // prevents this vehicle from coupling to another in Driver mode.
- Notes
- The mask can be built using the Coupler Flag constants.
- This method will not prevent vehicles from coupling in Surveyor, but takes effect in Driver mode.
SetDecouplingMask
public native void SetDecouplingMask(int mask)
- Parameters
- mask = A mask specifying which of the vehilce's couplers are allowed to couple.
- Returned Value
- None
- Syntax
SetDecouplingMask(COUPLE_NONE); // prevents this vehicle from uncoupling in Driver mode.
- Notes
- The mask can be built using the Coupler Flag constants.
- This method will not prevent vehicles from uncoupling in Surveyor, but takes effect in Driver mode.
SetHandbrake
public native void SetHandBrake(bool applied)
- Parameters
- applied = If true the handbrake is applied, if false the handbrake is released.
- Returned Value
- None
- Syntax
SetHandBrake(true);
- Notes
SetHeadlightColor
SetHeadlightColor(float red, float blue, float green)
- Parameters
- red, blue, green = RGB components of selected colour, expressed as normalised values.
- Returned Value
- None
- Syntax
SetHeadlightColour(0.5,1.0,0.5); // sets colour to RGB:128,255,128
- Notes
- This method controls the color of the illumination produced by the headlights.
- It does not affect the color of the headlight coronas.
- This should method not be used to "turn off" the headlights, as even a black light will consume CPU time with lighting calculations.
SetMaximumCouplerCompressionStress
public native void SetMaximumCouplerCompressionStress(float stress)
- Parameters
- stress = Maximum tensile stress in kilonewtons (kN), Use 0.0 to turn off this simulation. // please, check this
- Returned Value
- None
- Syntax
SetMaximumCouplerCompressionStress(1500.0);
- Notes
- Sets the maximum coupler expansion stress value for this vehicle.
- This value refers to the maximum expansion stress which this vehicle's couplers need to experience before they break.
- This is effectively the stress that a coupler can withstand before it breaks.
- As a point of reference, a typical modern knuckle-type coupler can handle approximately 2500 kN of force before breaking.
- This is roughly equivalent to the weight of 2.5 million apples.
SetMaximumCouplerExpansionStress
public native void SetMaximumCouplerExpansionStress(float stress)
- Parameters
- stress = Maximum compression stress in kilonewtons (kN), Use 0.0 to turn off this simulation.
- Returned Value
- None
- Syntax
SetMaximumCouplerExpansionStress(1000.0);
- Notes
- Sets the maximum coupler compression stress value for this vehicle.
- This value refers to the maximum compression stress which this vehicle's couplers need to experience before they break.
- This is effectively the stress that a coupler can withstand before it breaks.
- As a point of reference, a typical modern knuckle-type coupler can handle approximately 2500 kN of force before breaking.
- This is roughly equivalent to the weight of 2.5 million apples.
SetMaximumCoupleVelocity
public native void SetMaximumCoupleVelocity(float velocity)
- Parameters
- velocity = The maximum speed in metres per second at which this vehicle can be coupled to without breaking a coupler.
- Returned Value
- None
- Syntax
SetMaximumCoupleVelocity(10);
- Notes
- "Vehicle","BadCouple" are broadcast if this speed is exceeded.
- If a value of zero is used "Vehicle","BadCouple" messages will not be issued.
SetMaximumTractiveEffort
public native void SetMaximumTractiveEffort(float maxTE)
- Parameters
- maxTE = The maximum tractive effort of this vehicle in newtons (N).
- Returned Value
- None
- Syntax
SetMaximumTractiveEffort(185000.0);
- Notes
- The maximum tractive effort of a vehicle refers to its maximum traction or pulling power measured in newtons.
- This value is initially defined in the configuration of a vehicle asset but can be altered with this method.
- Generally, only locomotives will have tractive effort.
SetPitchBasedOnSpeed
public native void SetPitchBasedOnSpeed(float factor)
- Parameters
- factor = An arbitrary value used to vary the pitch of the train with its velocity.
- Returned Value
- None
- Syntax
SetPitchBasedOnSpeed(2.5);
- Notes
- Pitch is rotation about an axis at right angles to the track direction.
SetPitchBasedOnTrack
public native void SetPitchBasedOnTrack(bool pitch)
- Parameters
- pitch = True to enable the effect, false to disable.
- Returned Value
- None
- Syntax
SetPitchBasedOnTrack(true);
- Notes
- Pitch is rotation about an axis at right angles to the track direction.
SetProductDisabled
public native void SetProductDisabled(void)
- Parameters
- None
- Returned Value
- None
- Syntax
SetProductDisabled();
- Notes
- Disables the loading or unloading of any product, overriding any previous calls to SetProductRestriction().
SetProductRestriction
public native bool SetProductRestriction(Asset product)
- Parameters
- product = Asset to to which this vehicle's load is to be restricted.
- Returned Value
- True if successful, false otherwise.
- Syntax
SetProductRestriction(coal);
- Notes
- Restricts this vehicle to only allow the given product.
- When a product restriction is in effect, only that product may be either loaded or unloaded.
- This method overrides any previous call to SetProductDisabled().
- If the product parameter is null, any product compatible with this vehicle can be loaded/unloaded.
- If it is a product that is not compatible with this vehicle, no restriction is set and false will be returned.
SetQueueInitialCount
public void SetQueueInitialCount(ProductQueue queue, Asset product, int amount)
- Parameters
- queue = Queue to use, any existing products in this queue will be destroyed.
- product = Asset of product to use.
- amount = Amount of product to use.
- Returned Value
- None
- Syntax
SetQueueInitialCount(passengerQueue,passengers,20);
- Notes
- Fills the given queue with the specified quantity of product.
- This method sets the amount of products in the given queue.
- It is a utility method that works on the given queue which need not be a queue from this vehicle.
- The product filter provided with queue will be used to check if the queue can take products of type asset.
- If it can't, the filter will be modified to suit as this method is forceful in that regard.
SetRollBasedOnTrack
public native void SetRollBasedOnTrack(float factor)
- Parameters
- factor = Arbitrary value used to control the amount of roll.
- Returned Value
- None
- Syntax
SetRollBasedOnTrack(2.0);
- Notes
- Roll is a rotation about an axis parallel to the track direction.
- Use a positive value to lean 'into' the curve, a negative value to lean out.
SetRunningNumber
public native void SetRunningNumber(string number)
- Parameters
- number = The running (fleet identification) number of the vehicle.
- Returned Value
- None
- Syntax
SetRunningNumber("21C1"); SetRunningNumber("4472");
- Notes
- This value is retrieved using GetRunningNumber() and should be restricted to alphanumeric characters and spaces.
SetSandingTractionMultiplier
public native void SetSandingTractionMultiplier(float factor)
- Parameters
- factor = A multiplier value of 1.0 or more defining the increase in this vehicle's tractive effort when sand is in use.
- Returned Value
- None
- Syntax
SetSandingTractionMultiplier(1.5); // allow sanding to increase tractive effort by 50%
- Notes
SetWheelslipTractionMultiplier
public native void SetWheelslipTractionMultiplier(float factor)
- Parameters
- factor = A multiplier value of 1.0 or less to apply to decrease this vehicle's traction when wheelslip occurs.
- Returned Value
- None
- Syntax
SetWheelslipTractionMultiplier(0.25); // wheelslip reduces tractive effort to 25% of normal.
- Notes
- A multiplier value of 1.0 disables the wheelspin sound.
Uncouple
public native void Uncouple(int end)
public native void Uncouple(Vehicle other)
public native void Uncouple(Vehicle other)
- Parameters
- end = One of the Direction Relationship constants indicating at which end of the current vehicle the uncoupling is to occur.
- other = A reference to the other vehicle form which the caller is to be uncoupled.
- Returned Value
- None
- Syntax
Uncouple(DIRECTION_FORWARD); // uncouple at the current vehicle's front end Uncouple(vehicle1); // uncouple from the specified vehicle
- Notes
- This method will always cause another Train object to be created.
- The current Train reference will remain on the section of the previous train with the most drivers declared.
UnloadProduct
public bool UnloadProduct(LoadingReport report)
- Parameters
- report = Report on the current state of the loading operation.
- Returned Value
- True if the unloading operation was successful, false otherwise.
- Syntax
UnloadProduct(report);
- Notes
- Unloads products into this vehicle as defined by the given report.
- This method works by attempting to transfer products from this vehicle's queues to the industry queue specified in report.
- The sequence of events for an unloading operation as performed by this method is:
- Verify that an unloading operation is possible with this vehicle by calling CanUnloadProductToQueue().
- BeginUnload() on this vehicle and Industry.BeginUnload() on the industry specified in the report are called to perform any pre-unloading events like animation or particle effects on the vehicle and industry respectively.
- Both of these methods return the amount of time required for an unloading operation and the UnloadProduct() method sleeps for which ever of these times is the longer.
- The actual product transfer to the industry from the vehicle is performed by calling ProductQueue.TransferProductFrom() on the industry queue(s).
- GetUnloadTime() on this vehicle and Industry.GetUnloadTime() are called. Again, UnloadProduct() sleeps for which ever is the longer of the times returned.
- EndUnload() and Industry.EndUnload() are called to perform any post-loading events. As before UnloadProduct() sleeps for the longer time.
UpdateViewDetails
void UpdateViewDetails(Message msg)
- Parameters
- msg = Message object which triggers this handler.
- Returned Value
- None
- Notes
- Update the view details window for this vehicle (from the train).
- This method is setup by Init() as a handler method for a message of type "Vehicle","LoadComplete".
- Such a message indicates that the load or queue of the vehicle have changed and the view details window of the train will need to be updated.
ViewDetails
void ViewDetails(Message msg)
- Parameters
- msg = Message object which triggers this handler.
- Returned Value
- None
- Notes
- View details window for this vehicle using the Train's output.
- This method is setup by Init() as a handler method for a message of type "MapObject","ViewDetails".object.
- Such a message indicates that the user has opened the right-click menu of the vehicle and selected the "View Details" menu item.
- This method will call the ViewDetails() method of this vehicle's train so that a Browser window describing the entire train can be displayed to the user.
ViewSchedule
void ViewSchedule(Message msg)
- Parameters
- msg = Message object which triggers this handler.
- Returned Value
- None
- Notes
- View the schedule window for this vehicle from the train.
- This method is setup by Init() as a handler method for a message of type "MapObject","View-Schedule".
- Such a message indicates that the schedule of the vehicle or train is to be displayed for the user.
- This method calls through to Train.UpdateScheduleWindow().
NotifyTrainChanged
public void NotifyTrainChanged(Train prevTrain, Train nextTrain)
- Parameters
- prevTrain = The train to which this Vehicle was previously attached.
- nextTrain = The train to which this Vehicle is now attached.
- Returned Value
- None
- Notes
- In ts12 only.
- Override this function as required, but don't forget to call the inherited version in case it does something in the future.
- Attempting to manipulate the makeup or positioning of any Train from within this function is illegal behavior. If you need to do that, trigger a delayed action using a message or a thread.
Code Examples
Related Methods
Train.GetVehicles()
World.GetVehicleList()