Skip to content

Examples: MTC Speed Transmitter

Kenny Mensah edited this page Jan 15, 2020 · 2 revisions

Examples: MTC Speed Transmitter

The Speed Limit transmitter tells the person (or train itself) what the speed limit and next speed limit, as well as where it will be at.

Requirements

ComputerCraft. You can get the latest 1.7.10 version here.

Not required for this setup, but for this example, the computer is located right next to the transmitter:

Speed Transmitter under the tracks, and a computer to the side of the speed transmitter

Static Speed Limit

In this example, the computer sets the speed limit for the speed transmitter as 60, and the next speed limit to 0.

local speedTransmitter = peripheral.find("info_transmitter_speed") -- Finds a speed transmitter attached to the computer
local speedLimit = 60 -- The speed limit for the passing train
local nextSpeedLimit = 0 -- The next speed limit for the passing train

speedTransmitter.setSpeed(speedLimit) -- Sets the speed limit to 60, because we set it as so before
speedTransmitter.setNextSpeed(nextSpeedLimit) -- Sets the next speed limit to 0, because we set it as so before
speedTransmitter.activate() -- Activates the speed transmitter so trains passing over can get the speed limit

Next Speed Limit

In this example, the next speed limit is 30, and coordinates that it will switch to is at X 45, Y 64, and Z 54.

local speedTransmitter = peripheral.find("info_transmitter_speed") -- Finds a speed transmitter attached to the computer
local speedLimit = 60 -- The speed limit for the passing train
local nextSpeedLimit = 0 -- The next speed limit for the passing train

speedTransmitter.setSpeed(speedLimit) -- Sets the speed limit to 60, because we set it as so before
speedTransmitter.setNextSpeed(nextSpeedLimit) -- Sets the next speed limit to 0, because we set it as so before
speedTransmitter.setNextX(45) -- Sets the X position of the next speed limit
speedTransmitter.setNextY(64) -- Sets the Y position of the next speed limit
speedTransmitter.setNextZ(54) -- Sets the Z position of the next speed limit
speedTransmitter.activate() -- Activates the speed transmitter so trains passing over can get the speed limit

Changeable Speed Limit

In this example, the speed limit is 60, but is switched to 15 if there is a redstone input on the left side of the computer.

local speedTransmitter = peripheral.find("info_transmitter_speed") -- Finds a speed transmitter attached to the computer
local speedLimit = 60 -- The speed limit for the passing train
local nextSpeedLimit = 0 -- The next speed limit for the passing train

speedTransmitter.setSpeed(speedLimit) -- Sets the speed limit to 60
speedTransmitter.setNextSpeed(nextSpeedLimit) -- Sets the next speed limit to 0

if redstone.getInput("left") then -- If there is a redstone input on the left side...what next? 
speedTransmitter.setSpeed(15) -- Sets the speed limit to 15
else -- If not, then..
speedTransmitter.setSpeed(speedLimit) -- Sets the speed limit to 60
end

speedTransmitter.setNextSpeed(nextSpeedLimit) -- Sets the next speed limit to the one we defined before
speedTransmitter.activate() -- Activates the speed transmitter so trains passing over can get the speed limit

Anything else?

By these examples, (and the comments), you have learned how to set the speed limit of a speed limit block for MTC.

If you still need help, contact PeachMaster#9135 (or ((PeachMaster)chair.ridingEntity)) on the Discord. Happy coding!