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