
Untitled
By: a guest on
Apr 29th, 2012 | syntax:
None | size: 1.06 KB | hits: 18 | expires: Never
--Send format: <key>:<send>:<from>:<to>:<message>
-- Number format 1 2 3 4 5
--Receive format <key>:<receive>
-- Number format 1 2
rednet.open("back")
term.clear()
term.setCursorPos(1,1)
print("RFSA Voennaya sistema elektronnoi pochty")
while true do
id,msg = rednet.receive()
split(msg,":")
if msg[1]=="nikkita" then
if msg[2]=="send" then
idFrom = msg[3]
idTo = msg[4]
x = fs.open(msg[4],"w")
w.writeLine("From:")
w.writeLine(msg[3])
w.writeLine(msg[5])
x.close()
end
if msg[2]=="receive" then
x = fs.exists(id)
if x=="true" then
y = fs.open(id,"r")
rednet.send(id,y)
end
if x=="false" then
rednet.send(id,"false")
end
end
end
end
function split(pString, pPattern)
local Table = {}
local fpat = "(.-)" .. pPattern
local last_end = 1
local s, e, cap = pString:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(Table,cap)
end
last_end = e+1
s, e, cap = pString:find(fpat, last_end)
end
if last_end <= #pString then
cap = pString:sub(last_end)
table.insert(Table, cap)
end
return Table
end