Advertisement
Guest User

startup

a guest
Apr 6th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.61 KB | None | 0 0
  1. --Setup--------
  2. print("****Systemstart****")
  3. --..Rednet.....
  4. rednet.open("right")
  5. print("Rednet aktiviert")
  6. sleep(1)
  7. --G1a
  8. rednet.send(24, "start")
  9. sender24, message24, protocol24 = rednet.receive(1)
  10. if message24 == "start" then
  11.   print("Computer 24, Ausgang Gleis 1 verbunden")
  12. else
  13.   print("FEHLER! Computer 24 nicht verbunden")
  14. end
  15. --G2a
  16. rednet.send(25, "start")
  17. sender25, message25, protocol25 =rednet.receive(1)
  18. if message25 == "start" then
  19.   print("Computer 25, Ausgang Gleis 2 verbunden")
  20. else
  21.   print("FEHLER! Computer 25 nicht verbunden")
  22. end
  23. --W
  24. rednet.send(27, "start")
  25. sender27, message27, protocol27 = rednet.receive(1)
  26. if message27 == "start" then
  27.   print("Computer 27, Weichenschaltung verbunden")
  28. else
  29.   print("FEHLER! Computer 27 nicht verbunden")
  30. end
  31. --G201a
  32. rednet.send(22, "start")
  33. sender22, message22, protocol22 = rednet.receive(1)
  34. if message22 == "start" then
  35.   print("Computer 22, Ausgang Gleis 201 verbunden")
  36. else
  37.   print("FEHLER! Computer 22 nicht verbunden")
  38. end
  39. --G1e
  40. rednet.send(26, "start")
  41. sender26, message26, protocol26 = rednet.receive(1)
  42. if message26 == "start" then
  43.   print("Computer 26, Belegung Gleis 1 verbunden")
  44. else
  45.   print("FEHLER! Computer 26 nicht verbunden")
  46. end
  47. --G2e
  48. rednet.send(21, "start")
  49. sender21, message21, protocol21 = rednet.receive(1)
  50. if message21 == "start" then
  51.   print("Computer 21, Belegung Gleis 2 verbunden")
  52. else
  53.   print("FEHLER! Computer 21 nicht verbunden")
  54. end
  55. --G201e
  56. rednet.send(28, "start")
  57. sender28, message28, protocol28 = rednet.receive(1)
  58. if message28 == "start" then
  59.   print("Computer 28, Belegung Gleis 201 verbunden")
  60. else
  61.   print("FEHLER! Computer 28 nicht verbunden")
  62. end
  63. --G202e
  64. rednet.send(29, "start")
  65. sender29, message29, protocol29 = rednet.receive(1)
  66. if message29 == "start" then
  67.   print("Computer 29, Belegung Gleis 202 verbunden")
  68. else
  69.   print("FEHLER! Computer 29 nicht verbunden")
  70. end
  71. --Ad
  72. rednet.send(30, "start")
  73. sender30, message30, protocol30 = rednet.receive(1)
  74. if message30 == "start" then
  75.   print("Computer 30, Ankunftsdetektor verbunden")
  76. else
  77.   print("FEHLER! Computer 30 nicht verbunden")
  78. end
  79. sleep(1)
  80.  
  81. --..Gleise..
  82. print("****Gleisinitialisierung****")
  83. print("Strecke muss frei sein! Bitte ueberpruefen!")
  84. --Gleisbelegung
  85. G001 = false
  86. G002 = false
  87. G201 = false
  88. G202 = false
  89. --Freie Strecke
  90. Strecke = false
  91. RJona = false
  92. RDorf = false
  93. Ankunft = false
  94. --Abfahrtstimer
  95. A001 = false
  96. A002 = false
  97. print("Gleise initialisiert")
  98. sleep(1)
  99.  
  100. print("##System bereit##")
  101. sleep(3)
  102.  
  103. --Main---------
  104. while true do
  105. term.clear()
  106. term.setCursorPos(1,1)
  107.   --..CheckTrack..
  108.   --CheckTrack 1
  109.   rednet.send(26, "CheckTrack")
  110.   local id26, ct26, pr26 = rednet.receive(26)
  111.   if ct26 == "Frei" then
  112.     G001 = false
  113.     A001 = false
  114.     print("Gleis 1    FREI")
  115.   elseif ct26 == "Belegt" then
  116.     G001 = true
  117.     A001 = false
  118.     print("Gleis 1    BELEGT")
  119.   elseif ct26 == "LangB" then
  120.     G001 = true
  121.     A001 = true
  122.     print("Gleis 1    ABFAHRTSBEREIT")
  123.   end
  124.   --CheckTrack 2
  125.   rednet.send(21, "CheckTrack")
  126.   local id21, ct21, pr21 = rednet.receive(21)
  127.   if ct21 == "Frei" then
  128.     G002 = false
  129.     A002 = false
  130.     print("Gleis 2    FREI")
  131.   elseif ct21 == "Belegt" then
  132.     G002 = true
  133.     A002 = false
  134.     print("Gleis 2    BELEGT")
  135.   elseif ct21 == "LangB" then
  136.     G002 = true
  137.     A002 = true
  138.     print("Gleis 2    ABFAHRTSBEREIT")
  139.   end
  140.   --CheckTrack 201
  141.   rednet.send(28, "CheckTrack")
  142.   local id28, ct28, pr28 = rednet.receive(28)
  143.   if ct28 == "Frei" then
  144.     G201 = false
  145.     print("Gleis 201  FREI")
  146.   elseif ct28 == "Belegt" then
  147.     G201 = true
  148.     print("Gleis 201  BELEGT")
  149.   end
  150.   --CheckTrack 202
  151.   rednet.send(29, "CheckTrack")
  152.   local id29, ct29, pr29 = rednet.receive(29)
  153.   if ct29 == "Frei" then
  154.     G202 = false
  155.     print("Gleis 202  FREI")
  156.   elseif ct29 == "Belegt" then
  157.     G202 = true
  158.     print("Gleis 202  BELEGT")
  159.   end
  160.   --CheckTrack Ankunft
  161.   rednet.send(30, "CheckTrack")
  162.   local id30, ct30, pr30 = rednet.receive(30)
  163.   if ct30 == "Frei" then
  164.     Ankunft = false
  165.     print("Ankunft Bf NEIN")
  166.   elseif ct30 == "Belegt" then
  167.     Ankunft = true
  168.     print("Ankunft Bf JA")
  169.   end
  170.   print("------------------------------")
  171.  
  172.   --..Zuege Steuern
  173.   --Abfahrt Gleis 1
  174.   if A001 == true then
  175.     if Strecke == false and G202 == false then
  176.       rednet.send(24, "Abfahrt")
  177.       Strecke = true
  178.       RDorf = true
  179.       print("Abfahrt Gleis 1")
  180.     else
  181.     end
  182.   end
  183.   print("-")
  184.   --Abfahrt Gleis 2
  185.   if A002 == true then
  186.     if Strecke == false and G202 == false then
  187.       rednet.send(25, "Abfahrt")
  188.       Strecke = true
  189.       RDorf = true
  190.       print("Abfahrt Gleis 2")
  191.     else
  192.     end
  193.   end
  194.   print("-")
  195.   --Abfahrt Gleis 201
  196.   if G201 == true then
  197.     if Strecke == false then
  198.       if G001 == false or G002 == false then
  199.         rednet.send(22, "Abfahrt")
  200.         Strecke = true
  201.         RJona = true
  202.         print("Abfahrt Gleis 201")
  203.         term.setCursorPos(8,1)
  204.         if G001 == true then
  205.           rednet.send(27, "Weiche_2")
  206.           print("Weiche auf Gleis 2")
  207.         else
  208.           rednet.send(27, "Weiche_1")
  209.           print("Weiche auf Gleis 1")
  210.         end
  211.       end
  212.     end
  213.   end
  214.   print("-")
  215.   print("-")
  216.   print("------------------------------")
  217.   --Streckenfreischaltung
  218.   --..Nord
  219.   if G202 == true and RDorf == true then
  220.     Strecke = false
  221.     RDorf = false
  222.     print("Strecke Freigeschaltet")
  223.   end
  224.   --..Sued
  225.   if Ankunft == true then
  226.     Strecke = false
  227.     RJona = false
  228.     print("Strecke Freigeschaltet")
  229.   end
  230.   --Sonstige Anzeigen
  231.   print("Strecke ", Strecke)
  232.   sleep(2)
  233. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement