Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Setup--------
- print("****Systemstart****")
- --..Rednet.....
- rednet.open("right")
- print("Rednet aktiviert")
- sleep(1)
- --G1a
- rednet.send(24, "start")
- sender24, message24, protocol24 = rednet.receive(1)
- if message24 == "start" then
- print("Computer 24, Ausgang Gleis 1 verbunden")
- else
- print("FEHLER! Computer 24 nicht verbunden")
- end
- --G2a
- rednet.send(25, "start")
- sender25, message25, protocol25 =rednet.receive(1)
- if message25 == "start" then
- print("Computer 25, Ausgang Gleis 2 verbunden")
- else
- print("FEHLER! Computer 25 nicht verbunden")
- end
- --W
- rednet.send(27, "start")
- sender27, message27, protocol27 = rednet.receive(1)
- if message27 == "start" then
- print("Computer 27, Weichenschaltung verbunden")
- else
- print("FEHLER! Computer 27 nicht verbunden")
- end
- --G201a
- rednet.send(22, "start")
- sender22, message22, protocol22 = rednet.receive(1)
- if message22 == "start" then
- print("Computer 22, Ausgang Gleis 201 verbunden")
- else
- print("FEHLER! Computer 22 nicht verbunden")
- end
- --G1e
- rednet.send(26, "start")
- sender26, message26, protocol26 = rednet.receive(1)
- if message26 == "start" then
- print("Computer 26, Belegung Gleis 1 verbunden")
- else
- print("FEHLER! Computer 26 nicht verbunden")
- end
- --G2e
- rednet.send(21, "start")
- sender21, message21, protocol21 = rednet.receive(1)
- if message21 == "start" then
- print("Computer 21, Belegung Gleis 2 verbunden")
- else
- print("FEHLER! Computer 21 nicht verbunden")
- end
- --G201e
- rednet.send(28, "start")
- sender28, message28, protocol28 = rednet.receive(1)
- if message28 == "start" then
- print("Computer 28, Belegung Gleis 201 verbunden")
- else
- print("FEHLER! Computer 28 nicht verbunden")
- end
- --G202e
- rednet.send(29, "start")
- sender29, message29, protocol29 = rednet.receive(1)
- if message29 == "start" then
- print("Computer 29, Belegung Gleis 202 verbunden")
- else
- print("FEHLER! Computer 29 nicht verbunden")
- end
- --Ad
- rednet.send(30, "start")
- sender30, message30, protocol30 = rednet.receive(1)
- if message30 == "start" then
- print("Computer 30, Ankunftsdetektor verbunden")
- else
- print("FEHLER! Computer 30 nicht verbunden")
- end
- sleep(1)
- --..Gleise..
- print("****Gleisinitialisierung****")
- print("Strecke muss frei sein! Bitte ueberpruefen!")
- --Gleisbelegung
- G001 = false
- G002 = false
- G201 = false
- G202 = false
- --Freie Strecke
- Strecke = false
- RJona = false
- RDorf = false
- Ankunft = false
- --Abfahrtstimer
- A001 = false
- A002 = false
- print("Gleise initialisiert")
- sleep(1)
- print("##System bereit##")
- sleep(3)
- --Main---------
- while true do
- term.clear()
- term.setCursorPos(1,1)
- --..CheckTrack..
- --CheckTrack 1
- rednet.send(26, "CheckTrack")
- local id26, ct26, pr26 = rednet.receive(26)
- if ct26 == "Frei" then
- G001 = false
- A001 = false
- print("Gleis 1 FREI")
- elseif ct26 == "Belegt" then
- G001 = true
- A001 = false
- print("Gleis 1 BELEGT")
- elseif ct26 == "LangB" then
- G001 = true
- A001 = true
- print("Gleis 1 ABFAHRTSBEREIT")
- end
- --CheckTrack 2
- rednet.send(21, "CheckTrack")
- local id21, ct21, pr21 = rednet.receive(21)
- if ct21 == "Frei" then
- G002 = false
- A002 = false
- print("Gleis 2 FREI")
- elseif ct21 == "Belegt" then
- G002 = true
- A002 = false
- print("Gleis 2 BELEGT")
- elseif ct21 == "LangB" then
- G002 = true
- A002 = true
- print("Gleis 2 ABFAHRTSBEREIT")
- end
- --CheckTrack 201
- rednet.send(28, "CheckTrack")
- local id28, ct28, pr28 = rednet.receive(28)
- if ct28 == "Frei" then
- G201 = false
- print("Gleis 201 FREI")
- elseif ct28 == "Belegt" then
- G201 = true
- print("Gleis 201 BELEGT")
- end
- --CheckTrack 202
- rednet.send(29, "CheckTrack")
- local id29, ct29, pr29 = rednet.receive(29)
- if ct29 == "Frei" then
- G202 = false
- print("Gleis 202 FREI")
- elseif ct29 == "Belegt" then
- G202 = true
- print("Gleis 202 BELEGT")
- end
- --CheckTrack Ankunft
- rednet.send(30, "CheckTrack")
- local id30, ct30, pr30 = rednet.receive(30)
- if ct30 == "Frei" then
- Ankunft = false
- print("Ankunft Bf NEIN")
- elseif ct30 == "Belegt" then
- Ankunft = true
- print("Ankunft Bf JA")
- end
- print("------------------------------")
- --..Zuege Steuern
- --Abfahrt Gleis 1
- if A001 == true then
- if Strecke == false and G202 == false then
- rednet.send(24, "Abfahrt")
- Strecke = true
- RDorf = true
- print("Abfahrt Gleis 1")
- else
- end
- end
- print("-")
- --Abfahrt Gleis 2
- if A002 == true then
- if Strecke == false and G202 == false then
- rednet.send(25, "Abfahrt")
- Strecke = true
- RDorf = true
- print("Abfahrt Gleis 2")
- else
- end
- end
- print("-")
- --Abfahrt Gleis 201
- if G201 == true then
- if Strecke == false then
- if G001 == false or G002 == false then
- rednet.send(22, "Abfahrt")
- Strecke = true
- RJona = true
- print("Abfahrt Gleis 201")
- term.setCursorPos(8,1)
- if G001 == true then
- rednet.send(27, "Weiche_2")
- print("Weiche auf Gleis 2")
- else
- rednet.send(27, "Weiche_1")
- print("Weiche auf Gleis 1")
- end
- end
- end
- end
- print("-")
- print("-")
- print("------------------------------")
- --Streckenfreischaltung
- --..Nord
- if G202 == true and RDorf == true then
- Strecke = false
- RDorf = false
- print("Strecke Freigeschaltet")
- end
- --..Sued
- if Ankunft == true then
- Strecke = false
- RJona = false
- print("Strecke Freigeschaltet")
- end
- --Sonstige Anzeigen
- print("Strecke ", Strecke)
- sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement