Minecraft Train Control - EternalBlueFlame/Traincraft-5 GitHub Wiki

Minecraft Train Control

Minecraft Train Control (MTC) is a system designed to prevent overspeeding using blocks that transmit speed information, where to stop ahead, as well as station stops. It can also be used for automation of trains.

At the moment, it is designed to be an addition to a signaling system; you will still have to do the back end. Also, ComputerCraft is required, and in 022+, OpenComputers is supported. In the future these will no longer be the case.

Requirements

ComputerCraft. You can get the latest 1.7.10 version here.

(or) OpenComputers. You can download it here.

Basic Lua Skills: You can learn how to do it here.

Operation

This shows most of the possible indications that you can get while using MTC.

When MTC is started, a speed limit will be set from the Speed Transmitter block, or wirelessly from a radio. There is also a "Next Speed Limit", which allows drivers to know what the next speed limit will be. If the coordinates for where it will be is defined, there will also be displayed the distance to that new speed limit. If the distance to the next speed limit goes under the current speed limit, the speed limit will go down, following the distance to the next one, until it reaches the next speed limit, creating a braking curve. If the driver goes over the limit, it slows down the train to under the limit, to prevent overspeeding. This can be overriden using a keybind which you can change in the settings.

W-MTC is MTC but instead of using blocks, it is transmitted wirelessly from a computer. This kind of MTC allows automation in running trains, if the server allows it. It can only be used with most electric and some diesel trains. There is more details here.

Lines can be set by default to not enforce speed limits by using .enforceSpeedLimits(true / false) for regular MTC, or by sending enforceSpeedLimits = false with W-MTC.

The system can also allow stop points, for example a red signal or a mis-switched switch. The operation is similar to the next speed limit; the speed limit goes down if the distance to the stop point reaches it. It goes down until 40km/h, which is the highest speed the driver can go until it is changed by a speed update.

MTC information screen The Minecraft Train Control Setup screen.

The Minecraft Train Control Setup screen allows you to change the ID of your train. It is not necessary, as it is generated automatically when you spawn the train. Changing the train level may change what speed limits you get, because you can set it up for you to get a different speed limit depending on the level. And finally, the destination is for Railcraft routing, or for use with MTC Destination Receiver blocks. Getting the destination with MTC uses Destination Receiver blocks.

Station stops are like regular stops, except that they don't make the speed limit change and is used for automation with Wireless MTC (W-MTC).

The MTC status are for the status of the system. It is as follows:

  • 0 = Inactive
  • 1 = Active
  • 2 = Ending Soon

A train level is a number that indicates what kind of train this is. This can vary from railroad to railroad, so try to check what levels they define for what kind of train.

If you do not like the system altogether, it can be toggled with a keybind in the settings. This prevents you from having automation, and advance speed limit systems.

Implementation

To use the system, ComputerCraft or OpenComputers must be installed, or else the blocks won't show up in the creative menu or can't be crafted.

Every block that is used must be activated. This is done by wrapping the peripheral with the computer, and using the activate() function. It can be deactivated with deactivate().

In OpenComputers, you need to get the UUID of the peripheral, put require("component") at the top of your code, then proxy it by thing = component.proxy("theUUID").

Speed Transmitter

This transmits the speed information to the train.

.setSpeed() : This sets the speed limit for the transmitter in km/h.

speedTransmitter.setSpeed(60)

.setNextSpeed() : This sets the next speed limit for the transmitter in km/h.

speedTransmitter.setNextSpeed(60)

.setNextX() : This sets the X coordinate for the next speed limit.

speedTransmitter.setX(1341.4)

.setNextY() : This sets the Y coordinate for the next speed limit.

speedTransmitter.setY(70)

.setNextZ() : This sets the Z coordinate for the next speed limit.

speedTransmitter.setZ(2515.1)

Stop Point Transmitter

This transmits the stop point information to the train.

.setNextX() : This sets the X coordinate for the next speed limit.

speedTransmitter.setX(431.3)

.setNextY() : This sets the Y coordinate for the next speed limit.

speedTransmitter.setY(72)

.setNextZ() : This sets the Z coordinate for the next speed limit.

speedTransmitter.setZ(4313)

MTC Transmitter

This transmits MTC information to the train.

.setMTCStatus() This sets the MTC status for the transmitter.

mtcTransmitter.setMTCStatus(2)

.setSignalBlock() Only used for W-MTC, sets the signal block that the train is in.

mtcTransmitter.setSignalBlock("TTF-1")

.setServerUUID() Only used for W-MTC, sets the UUID for the server and attempts a connection. If end is used instead of a UUID, it will make the train terminate all connections with the server.

mtcTransmitter.setServerUUID("47ba5d8c-a9af-420d-8dfc-2021d0833363")

MTC Destination Receiver

This gets the destination of the passing train.

.getDestination() This gets the destination of the train that is over it. (Returns String)

print(dreceiver.getDestination())

.isTrainOverSensor() This checks if a train is over the sensor. It returns true when a train is over it, and false when there isn't.

if dreceiver.isTrainOverSensor() then
    print("The train is over the sensor!")
else
    print("The train is not over the sensor!")
end

MTC Receiver

.getMTCLevel() This gets the MTC level of the passing train. (Returns integer)

print(receiver.getMTCLevel())

.getMTCName() This gets the train name of the passing train. (Returns string)

print(receiver.getMTCName())

.getMTCType() This gets the train type of the passing train. (Returns string, eg electric, diesel)

print(receiver.getMTCType())

.isTrainOverSensor() This checks if a train is over the sensor. It returns true when a train is over it, and false when there isn't.

if dreceiver.isTrainOverSensor() then
    print("The train is over the sensor!")
else
    print("The train is not over the sensor!")
end

.getTrainID() This gets the train ID of the passing train. (Returns string)

print(receiver.getTrainID())

Need further help?

If you are confused, try asking in the Traincraft Discord server. Someone or most likely me will be happy to answer. Happy coding 😄