Posted 21 September 2016 - 04:09 PM
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 useand then putlocal 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
if you want it to always happen and only update when the redstone changes you could do thisif 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
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
I have used your code and found a display error. When the train leaves the station, the "No train" message is off the screen using a 1x6 monitor.
I defined the monitor at the top, cleared the screen before code is executed, then set the Cursor Position to 1,1. Everything is then printed on the screen.
local mon = peripheral.wrap("<side>") –Defines the side of the monitor
local x = rs.getInput("<side>")
mon.clear() –Clears the monitor
mon.setTextScale(2) –Sets the size of the text
while true do
os.pullEvent("redstone")
if rs.getInput("<side>") then
mon.clear()
mon.setCursorPos(1,1)
mon.write("The Train Has Arrived…")
else
mon.clear()
mon.setCursorPos(1,1) –Sets the location of the cursor
mon.write("Awaiting Train")
end
end