This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
mariocoin's profile picture

Traincraft Train Station

Started by mariocoin, 11 September 2014 - 03:07 AM
mariocoin #1
Posted 11 September 2014 - 05:07 AM
I have a modded server that I set up for a few of my friends to play on, and on it I have lots of mods, including traincraft, and computer craft. I wanted to build a train station with those two mods that goes to various destinations, and at those destinations, the same stations as the first. In the station would be a waiting room, and monitors at the front of it, and it would have monitors on it, which is connected to a computer with a networking cable. I wanted to make it so that when a train stops at the platform on a detector rail, it would display on the monitor, "Train 1 has arrived!" Other wise, when the train leaves the station, it would say, " Awaiting train one." I tried the Redstone detection program, but that didn't work, and honestly I don't want to use Redstone torches and signs. Does anyone have a program for this?
Dragon53535 #2
Posted 11 September 2014 - 07:47 AM
So you want that when a train stops on a detector rail, that the redstone signal then goes into a computer and then that puts text onto a monitor if the train is there or not? You could use

local x = rs.getInput("<side>") --# this checks the side you specify for what it's current state is, on or off. change side to the side that the redstone is coming in on
and then put

if x then --# if redstone is on
  print("train is here") --# you'd need to edit these for monitors, this is just the detection
else --# if the redstone is off
  print("No train...")
end
if you want it to always happen and only update when the redstone changes you could do this

while true do --# causes the code to come back to here whenever it reaches the end
  os.pullEvent("redstone") --# will stop until redstone around the computer changes state
  if rs.getInput("<side>") then --# if it's on
	--# Train here stuff
  else
	--# Train not here stuff
  end
end
Edited on 11 September 2014 - 05:47 AM