The minitrain
The minitrain is the small train the player can drive. It has a fuel tank and a power switch. Text in brackets at the end of a note is extra detail for experienced modders, and you can skip it on a first read.
Trains the minitrain the player uses
Use Minitrain to read the minitrain the player uses.
public static class Trains
{
public static MinitrainInfo Minitrain { get; }
}
| Property | Type | What it means |
|---|---|---|
Minitrain | MinitrainInfo | The minitrain the player uses, or the first one found. null when there is none. |
MinitrainInfo a snapshot of the minitrain
Trains.Minitrain gives you one of these, or null when there is no minitrain in the loaded scene. It is the minitrain the player is using if there is one, otherwise the first one found. (It reads the game’s Minitrain.)
public sealed class MinitrainInfo
{
public float Fuel { get; }
public float Capacity { get; }
public bool Running { get; }
public float Speed { get; }
}
| Property | Type | What it means |
|---|---|---|
Fuel | float | How much fuel is in the tank now. |
Capacity | float | How much fuel the tank holds when full. |
Running | bool | true when the minitrain’s power switch is on. |
Speed | float | How fast the minitrain is going. |
Things to know
Trains.Minitrainis the minitrain the player is using, or the first one in the scene when the player is not using one. It isnullwhen the scene has no minitrain. To ask whether the player is driving, useTravel.UsingMinitrain. (It isMinitrain.playerUsing, which the game sets inChangePlayerUsingStateand restores when a save loads. The framework searches the active objects of the active scene.)FuelandCapacityare0when the minitrain has no fuel tank. (They arefuelTank.currentFuelAmountandfuelTank.maxFuelAmount.)Runningturns itself off when the tank runs dry. The game does that, not the framework. (It isMinitrain.isOn.)Speedis the speed of the train on the track that the minitrain drives. (It isGetTrain().currentSpeed.)
Limits
- You can’t add fuel. The fuel tank has no call that adds a given amount. Its only filling call takes the fuel out of the player’s inventory, which is the game’s own refuelling action and not a plain “add fuel”. (That call is
FillTankFromInventory.)