Jump to content




Train Monitor Program


  • You cannot reply to this topic
4 replies to this topic

#1 X3ME

  • Members
  • 82 posts
  • LocationBeing the stereotypical kid in forums.

Posted 11 September 2014 - 05:14 PM

Hey i am looking for a program that displays this message:

Line 2 Track 4
Waiting for Train

and changes to

Line 2 Track 2

Careful Boarding into train

Train is here

when it receives a redstone input from top

Thanks,

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 11 September 2014 - 05:26 PM

Do you have any code to show? We can help you write it. Otherwise, if you just want someone to make it for you, I can move this to the General section, as we usually don't do requests.

#3 X3ME

  • Members
  • 82 posts
  • LocationBeing the stereotypical kid in forums.

Posted 11 September 2014 - 05:39 PM

View PostX3ME, on 11 September 2014 - 05:14 PM, said:

Hey i am looking for a program that displays this message:

Line 2 Track 4
Waiting for Train

and changes to

Line 2 Track 2

Careful Boarding into train

Train is here

when it receives a redstone input from top

Thanks,

Yes i do:

I have written this: (but it doesnt work)

while true do
os.pullEvent ("redstone")
print ("Line 2 Track 4")
if rs.getInput ("back") then
print ("Line 2 Track 4")
print (" Careful Boarding into train")
print (" Train is Here
shell.run ("test")
end
end

#4 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 11 September 2014 - 06:49 PM

Is this the only code you've written? Because you're right, none of it would work.
while true do
  os.pullEvent("redstone")
  print("Line 2 Track 4")
  if rs.getInput("back") then
    print("Line 2 Track 4")
    print(" Careful Boarding into train")
    print(" Train is Here")
    shell.run ("test")
  end
end
This code is nearly exactly what you've written, and shouldn't have any errors, but to me, it seems that you're missing a huge portion of what you'd actually want.
If I read it right, you want it to constantly write "Line 2 Track 4" until it recieves a redstone signal from the top side of the computer.
while true do
  --#Clear the screen at the start of every loop
  term.clear()
  term.setCursorPos(1,1)
  --#Write initial message
  write("Line 2 Track 4")
  --#Wait for an event, and put the parameters into a table
  local events = {os.pullEvent()}
  --#If the event recieved is the one we want, continue to the rest of the code, else restart the loop
  if events[1] == "redstone" and events[2] == "top" then
    --#Write secondary message
    term.setCursorPos(1,1)
    --#"\n" is the new line indicator. You can use this to have the terminal automatically start a new line after this indicator.
    write("Line 2 Track 2\nTrain has arrived. Please be careful boarding the train")
    shell.run("test")
    --#I'm not sure what "test" is, but if it's the name of this program you're running,
    --#then I'd suggest to not have this line, and instead have your program labelled as "startup"
  end
end
This should be a bit better for what you want.

#5 X3ME

  • Members
  • 82 posts
  • LocationBeing the stereotypical kid in forums.

Posted 11 September 2014 - 10:08 PM

Thanks. I am mobile but i will try it ASAP





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users