SHOW:
|
|
- or go back to the newest paste.
| 1 | local tArgs = { ... }
| |
| 2 | -- | |
| 3 | local timeout = 3 | |
| 4 | local responses = {}
| |
| 5 | -- | |
| 6 | if #tArgs < 1 then | |
| 7 | print("Program is designed to get Informations Wireless")
| |
| 8 | print("usage: get teleporters")
| |
| 9 | return | |
| 10 | end | |
| 11 | programmname=tArgs[1] | |
| 12 | -- | |
| 13 | modem=peripheral.find("modem")
| |
| 14 | if not modem then | |
| 15 | print("kein modem - kein dienst.")
| |
| 16 | return | |
| 17 | end | |
| 18 | modemside=peripheral.getName(modem) | |
| 19 | rednet.open(modemside) | |
| 20 | -- | |
| 21 | if programmname == "teleporters" then | |
| 22 | - | rednet.broadcast("get Teleporter")
|
| 22 | + | rednet.broadcast("get teleporter","protocol1")
|
| 23 | local timerID = os.startTimer(timeout) | |
| 24 | print("waiting for Responses")
| |
| 25 | while true do | |
| 26 | local event, id, message, protocol = os.pullEvent() | |
| 27 | - | if event == "rednet_message" and protocol == "my_protocol" then |
| 27 | + | if event == "rednet_message" and protocol == "protocol1" then |
| 28 | responses[id] = message | |
| 29 | elseif event == "timer" and id == timerID then | |
| 30 | break | |
| 31 | end | |
| 32 | end | |
| 33 | file=fs.open("teleporters","w")
| |
| 34 | for computerID, msg in pairs(responses) do | |
| 35 | - | file.writeLine(computerID..", "..msg) |
| 35 | + | file.writeLine(msg) |
| 36 | end | |
| 37 | file.close() | |
| 38 | end | |
| 39 |