Examples: MTC Destination Receiver - EternalBlueFlame/Traincraft-5 GitHub Wiki
Examples: MTC Destination Receiver
The destination of a train is a Railcraft integration thing, however, it can be used with MTC as well. Here are some examples on how to do so.
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 destination
In this example, it will check if a train is over the destination receiver and it will print it out to the terminal of your ComputerCraft computer.
local destinationReceiver = peripheral.find("info_receiver_destination") -- Finds a destination receiver attached to the computer
destinationReceiver.activate() -- Turns it on
if destinationReceiver.isTrainOverSensor() then --If a train is over the destination receiver, then..
print(destinationReceiver.getDestination())
end
Print the destination to a monitor
In this example, it will check if a train is over the destination receiver and will show it on a monitor.
local destinationReceiver = peripheral.find("info_receiver_destination") -- Finds a destination receiver attached to the computer
destinationReceiver.activate() -- Turns it on
local monitor = peripheral.find("monitor") -- Finds a monitor attached to the computer
if destinationReceiver.isTrainOverSensor() then --If a train is over the destination receiver, then..
monitor.clear() -- Clears the monitor screen
monitor.setCursorPos(1,1) -- Sets the cursor position to the top
monitor.write(destinationReceiver.getDestination()) -- Puts it on the monitor
end
Print different things depending on what the destination is
In this example, it will check if a train is over the destination receiver, but print out different things depending on what the destination is.
local destinationReceiver = peripheral.find("info_receiver_destination") -- Finds a destination receiver attached to the computer
destinationReceiver.activate() -- Turns it on
if destinationReceiver.isTrainOverSensor() then -- If a train is over the sensor, then..
if destinationReceiver.getDestination() == "Light City" then -- If the destination of the train is Light City..
print("This train is to Light City, please use Platform A.")
elseif destinationReceiver.getDestination() == "Oakville" then -- If it's not Light City, and it's Oakville, then..
print("This train is to Oakville, please use Platform B.")
end
Anything else?
By these examples, (and the comments), you have learned how to set the MTC type, serverUUID, and signal block for the MTC Status Transmitter.
If you still need help, contact PeachMaster#9135 (or ((PeachMaster)chair.ridingEntity)) on the Discord. Happy coding!