function OpenAll()
for _,side in ipairs(rs.getSides()) do
rednet.open(side)
end
end
function split(str, pat)
local t = { }
local fpat = "(.-)"..pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
function runApp()
OpenAll()
id, msg, d = rednet.receive()
if msg ~= nil then
t = split(msg, "!SP!")
usr = t[1]
cmd = t[2]
if cmd == nil then
runApp()
end
print("--------------------------------------------------")
print("USER: "..usr)
print("COMMAND: "..cmd)
if cmd == "search" then
usr2 = t[3]
print("USER 2: "..usr2)
print("--------------------------------------------------")
elseif cmd == "status update" then
status = t[3]
print("STATUS: "..status)
print("--------------------------------------------------")
elseif cmd == "makeUser" then
password = t[3]
print("PASSWORD: "..password)
print("--------------------------------------------------")
elseif cmd == "logIn" then
password = t[3]
print("PASSWORD: "..password)
print("--------------------------------------------------")
elseif cmd == "sndfrq" then
usr2 = t[3]
print("USER 2: "..usr2)
print("--------------------------------------------------")
elseif cmd == "add friend" then
usr2 = t[3]
print("USER 2: "..usr2)
print("--------------------------------------------------")
elseif cmd == "list" then
print("--------------------------------------------------")
elseif cmd == "deleteUser" then
usr2 = t[3]
print("--------------------------------------------------")
elseif cmd == "listUsers" then
print("--------------------------------------------------")
end
if cmd == "search" then
if fs.isDir("RedBook/"..usr2) == false then
rednet.send(id, "USER DOES NOT EXIST")
else
if fs.exists("RedBook/"..usr2.."/status") == true then
usrstatus1 = fs.open("RedBook/"..usr2.."/status", "r")
usrstatus = usrstatus1.readAll()
usrstatus1.close()
end
x = usr2.."!SP!"..usrstatus.."!SP!"
rednet.send(id, x)
end
runApp()
elseif cmd == "status update" then
f = fs.open("RedBook/"..usr.."/status", "w")
f.write(status)
f.close()
runApp()
elseif cmd == "list" then
h = fs.open("RedBook/"..usr.."/friendlist", "a")
h.close()
friends = fs.open("RedBook/"..usr.."/friendlist", "r")
xyz = friends.readAll()
print(xyz)
rednet.send(id, xyz)
runApp()
elseif cmd == "sndfrq" then
check = fs.open("RedBook/"..usr2.."/friendlist", "r")
chck2 = check.readAll()
chck3 = split(chck2, "!SP!")
check.close()
a = fs.open("RedBook/"..usr2.."/friendreq", "a")
a.write("RedBook/"..usr.."!SP!")
a.close()
runApp()
elseif cmd == "chck frnd req" then
if fs.exists("RedBook/"..usr.."/friendreq") == false then
go = fs.open(usr.."/friendreq", "a")
go.close()
end
chck = fs.open("RedBook/"..usr.."/friendreq", "r")
cv = chck.readAll()
chck.close()
clear = fs.open("RedBook/"..usr.."/friendreq", "w")
clear.close()
print(cv)
rednet.send(id, cv)
print("SENT")
print("--------------------------------------------------")
chck.close()
runApp()
elseif cmd == "add friend" then
print(usr2)
nFriend = usr2.."!SP!"
nFriend2 = usr.."!SP!"
print(nFriend)
gol = fs.open("RedBook/"..usr.."/friendlist", "a")
gol.write(nFriend)
gol.close
gold = fs.open("RedBook/"..usr2.."/friendlist", "a")
if fs.exists("RedBook/"..usr2.."/friendlist") then
gold.write(nFriend2)
else print("File does not exist") end
gold.close()
runApp()
elseif cmd == "logIn" then
if fs.isDir("RedBook/"..usr) == true then
w = fs.open("RedBook/"..usr.."/password", "r")
y = w.readAll()
if y == password then
rednet.send(id, "YOU HAVE BEEN LOGGED IN")
else
rednet.send(id, "ERROR: WRONG PASSWORD")
end
else
rednet.send(id, "ERROR: WRONG USERNAME")
end
runApp()
elseif cmd == "makeUser" then
fs.makeDir("RedBook/"..usr)
make1 = fs.open("RedBook/"..usr.."/friendreq", "a")
make1.close()
make2 = fs.open("RedBook/"..usr.."/status", "a")
make2.close()
make3 = fs.open("RedBook/"..usr.."/friendlist", "a")
make3.close()
make4 = fs.open("RedBook/"..usr.."/password", "w")
make4.write(password)
make4.close()
rednet.send(id, "USER HAS BEEN CREATED")
runApp()
elseif cmd == "listUsers" then
list = fs.list("RedBook/")
list2 = textutils.serialize(list)
rednet.send(id, list2)
runApp()
elseif cmd == "deleteUser" then
if fs.exists("RedBook/"..usr2) then
fs.delete("RedBook/"..usr2)
rednet.send(id, "USER IS GONE >:^D")
else
rednet.send(id, "USER DOES NOT EXIST")
end
runApp()
end
end
end
runApp()
The error says:
bios:206: [string "server"]:130: '=' expected