SHOW:
|
|
- or go back to the newest paste.
| 1 | -- Wireless MODEM | |
| 2 | - | rednet.open("top")
|
| 2 | + | if fs.exists(".settings") == false then
|
| 3 | - | local modem = peripheral.wrap("right")
|
| 3 | + | v = 1 |
| 4 | else | |
| 5 | shell.run(".settings")
| |
| 6 | v = 0 | |
| 7 | rednet.open(side) | |
| 8 | modem = peripheral.wrap(lanSide) | |
| 9 | end | |
| 10 | ||
| 11 | while true do | |
| 12 | if v == 0 then | |
| 13 | ||
| 14 | ids, msg, ptrc = rednet.receive() | |
| 15 | ||
| 16 | print("Ricevuto "..msg)
| |
| 17 | print("Inoltro richiesta a "..msg..":80")
| |
| 18 | ||
| 19 | modem.sendChannel(80, msg) | |
| 20 | ||
| 21 | modem.setListening(80, true) | |
| 22 | local event, side, id, chn, mess = os.pullEvent("lan_message")
| |
| 23 | ||
| 24 | print("Ricevuto risposta da: 144.91.97."..id)
| |
| 25 | ||
| 26 | sleep(2) | |
| 27 | ||
| 28 | rednet.send(ids, mess) | |
| 29 | ||
| 30 | elseif v == 1 then | |
| 31 | print("Inserisci il lato del wm:")
| |
| 32 | local side = read() | |
| 33 | print("Ora inserisci il lato del modem LAN:")
| |
| 34 | local lanSide = read() | |
| 35 | file = fs.open(".settings", "w")
| |
| 36 | file.writeLine("side = '"..side.."'")
| |
| 37 | file.writeLine("lanSide = '"..lanSide.."'")
| |
| 38 | file.close() | |
| 39 | end | |
| 40 | sleep(0.5) | |
| 41 | end | |
| 42 | ||
| 43 | ||
| 44 |