Jharakn

Station Controller

Mar 7th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. -- ** ************************ ** --
  2. -- ** Train Station Controller ** --
  3. -- ** ************************ ** --
  4.  
  5. local monitor = peripheral.wrap("left")
  6. local stationName = "name1"
  7. local counter = 0
  8. local departureWait = 30
  9. local redstoneSide = "back"
  10.  
  11. function waitingPrint(counter)
  12. monitor.setCursorPos(1, 1)
  13. monitor.clear()
  14.  
  15. monitor.setCursorPos(1, 1)
  16. monitor.write("Welcome to "..stationName.." station")
  17.  
  18. monitor.setCursorPos(1, 3)
  19. monitor.write("Train departed "..counter.." Seconds ago")
  20. end
  21.  
  22. function departingPrint(counter)
  23. monitor.setCursorPos(1, 1)
  24. monitor.clear()
  25.  
  26. monitor.setCursorPos(1, 1)
  27. monitor.write("Welcome to "..stationName.." station")
  28.  
  29. monitor.setCursorPos(1, 3)
  30. monitor.write("Train departing in "..counter.." Seconds")
  31. end
  32.  
  33.  
  34. -- Main Program Loop
  35. while true do
  36. waitingPrint(counter)
  37. counter = counter + 1
  38. sleep(1)
  39.  
  40. if colors.test(redstone.getBundledInput(redstoneSide), colors.white) then
  41. sleep(2)
  42. redstone.setBundledOutput(redstoneSide, colors.orange)
  43. counter = departureWait
  44.  
  45. while counter ~= 0 do
  46. departingPrint(counter)
  47. counter = counter - 1
  48. sleep(1)
  49. end
  50.  
  51. redstone.setBundledOutput(redstoneSide, 0)
  52. sleep(2)
  53. redstone.setBundledOutput(redstoneSide, colors.magenta)
  54. sleep(2)
  55. redstone.setBundledOutput(redstoneSide, 0)
  56. end
  57.  
  58. if counter == 1000 then
  59. os.shutdown()
  60. end
  61. end
Advertisement
Add Comment
Please, Sign In to add comment