Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.host("main", "TRAIN")
- peripheral.find("modem", rednet.open)
- if not pocket then
- printError("Not pocket!")
- end
- print("press F to start train")
- print("press G to check computers")
- print("press H to turn on automatic mode (irrevocably)")
- while true do
- local eventData = {os.pullEvent()}
- local event = eventData[1]
- if event == "key" then
- if eventData[2] == 70 then
- print("Starting train")
- rednet.broadcast("GO","TRAIN")
- elseif eventData[2] == 71 then
- local computers = {rednet.lookup("main")}
- print(#computers .. " computers connected to main protocol")
- print("--------CONNECTED COMPUTERS---------")
- for _, computer in pairs(computers) do
- print("Computer #" .. computer)
- end
- print("--------CONNECTED COMPUTER---------")
- elseif eventData[2] == 72 then
- print("Turning on automatic")
- rednet.broadcast("OFF")
- end
- elseif event == "rednet_message" then
- if eventData[3] == "OK" then
- print("Train started")
- elseif eventData[3] == "NF" then
- printError("Train not finded on main station")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement