View difference between Paste ID: x7BKvj2H and peCQzp0E
SHOW: | | - or go back to the newest paste.
1
    -- This is my ComputerCraft eMail client code.
2
    -- if you want the server, goto http://pastebin.com/FC1Lp6qH
3
    local tArgs = { ... }
4-
	rednet.open("right")
4+
	local function openRednet()
5
local listOfSides = rs.getSides()
6
local listofPossibles = {}
7
local counter1 = 0
8
while true do
9
  counter1 = counter1 +1
10
 
11
  if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then
12
   table.insert(listofPossibles,tostring(listOfSides[counter1]))
13
  end
14
 
15
  if counter1 == 6 and table.maxn(listofPossibles) == 0 then
16
   print("no wifi present")
17
   return nil
18
  end
19
 
20
  if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
21
   rednet.open(listofPossibles[1])
22
   return listofPossibles[1]
23
  end
24
end
25
end
26
modemOn = openRednet()
27
    if tArgs[1] == "read" then
28
	rednet.broadcast(tArgs[2])
29
    a, messagep = rednet.receive(1)
30
    if messagep == null then
31
    else
32
    print("You've Got Mail!")
33
    print("------------------")
34
    print(messagep)
35
    end
36
	else if tArgs[1] == "send" then
37
    rednet.broadcast("sendmail")
38
    write("To: (in ID) ")
39
    input = read()
40
    rednet.broadcast(input)
41
    print("Message body:")
42
    input = read()
43
    rednet.broadcast(input)
44
    else
45
	print("Usage:")
46
    print("mail read (mailid)")
47
	print("mail send")
48
end
49
end