Posted 21 December 2014 - 06:44 AM
i have spent abut 2 hours trying to get this right, on line 30, i always keep getting the error of unexpected symbol. What I am attempting to do is add a key with data adding table.insert. This is the base of a chat server I am attempting to set up the chat server for some friends(to show off a bit too).
rednet.open("right")
users={admin=1,apple=1}--ID of all members on the server
--------------functions--------
function displayusers()
for i=1,#users do
print ("ID:"..users[i][1].." nick:"..users[i][2])
end
end
function receive()
while true do
id,msg=rednet.receive()
decide(id,msg)
end
end
function send(msg,id)
for i in users() do
end
end
function decide(id,msg,users)--deciding what each message is
i=1
command={}
for word in msg:gmatch("%a+") do
command[i]=word
i=i+1
end
if command[1]=="register" then--if register works
table.insert(users,[#users+1],command[2]=id)
rednet.send(id,"welcome,"..command[2].."!")
print(id.." has registered as "..command[2])
displayusers()
else-- if register did not work
print("not registered")
rednet.send(id,"your registery has not gone through")
print(id.." received an error")
print("[message]"..msg)
end
end
--main function
function status()
term.clear()
term.setCursorPos(1,1)
print("server is running...version A.1.01")
displayusers()
end
----------running--------
status()
receive()
(sorry if it is a bit cluttered, i have only been using computercraft about 6 days and am a bit new to it still in syntax)