Examples: MTC Status Receiver - EternalBlueFlame/Traincraft-5 GitHub Wiki
Examples: MTC Status Receiver
The Status Receiver is used to get information of passing trains, like it's level, it's train name, it's MTC type, and it's ID.
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:
Print the train level of the passing train.
The train level is an extra value that can be set in the MTC GUI, for identification. For example, a speed limit can be different if a train level is different. In this example, it checks if a train is over the status receiver, and prints it out.
local statusReceiver = peripheral.find("info_receiver_mtcdata") -- Finds a MTC Status Receiver
statusReceiver.activate() -- Activates so it can receive
if statusReceiver.isTrainOverSensor() then -- If a train is over the sensor, then..
print(statusReceiver.getMTCLevel()) -- The level of the passed train
end
Print the name of the passing train.
The train name is something like, "High Speed Locomotive", or "BR 185." It shows up in the inventory.
local statusReceiver = peripheral.find("info_receiver_mtcdata") -- Finds a MTC Status Receiver
statusReceiver.activate() -- Activates so it can receive
if statusReceiver.isTrainOverSensor() then -- If a train is over the sensor, then..
print(statusReceiver.getMTCName()) -- The name of the passing train.
end
Print the type of the passing train.
The type can be either electric, diesel, or steam. (Or nuclear if it's in the future)
local statusReceiver = peripheral.find("info_receiver_mtcdata") -- Finds a MTC Status Receiver
statusReceiver.activate() -- Activates so it can receive
if statusReceiver.isTrainOverSensor() then -- If a train is over the sensor, then..
print(statusReceiver.getMTCType()) -- The type of train that passed
end
Prints the train ID of the passing train.
The trainID is a unique identifier generated each time a train is placed down. It can be used to separate trains from others.
local statusReceiver = peripheral.find("info_receiver_mtcdata") -- Finds a MTC Status Receiver
statusReceiver.activate() -- Activates so it can receive
if statusReceiver.isTrainOverSensor() then -- If a train is over the sensor, then..
print(statusReceiver.getTrainID()) -- The type of train that passed
end