-
Notifications
You must be signed in to change notification settings - Fork 60
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.
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:
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
endThe 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.
endThe 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
endThe 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