Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- charlist = {}
- function init()
- print("Name?")
- name = io.read()
- serverId = rednet.lookup("chatServ","chatServer")
- if serverId ~= nil then
- rednet.send(serverId,"PING","chatServ")
- id, msg = rednet.receive("chatServ")
- if msg == "PONG" then
- if id == serverId then
- rednet.send(id,name)
- return serverId, true
- else
- error("An unknown computer sent a message during handshake... aborting!")
- end
- else
- error("Handshake interrupted for some reason... Aborting!")
- end
- else
- error("You need a server to connect to, silly!")
- end
- end
- function send(charlist,id)
- msg = " "
- for k,v in pairs(charlist) do
- msg = msg..tostring(charlist[k])
- end
- rednet.send(id,msg)
- end
- function main(serverid)
- event, idKey, msg = os.pullEvent()
- if event == "rednet_message" then
- elseif event == "char" then
- table.insert(charlist,m,idKey)
- m=m+1
- elseif event == "key_up" then
- if idKey == 28 then
- send(charlist,serverid)
- end
- end
- end
- --------
- m=0
- if textutils.serialize(peripheral.getNames()) ~= "{}" then
- rednet.open("back")
- else
- error("you need to put a wireless modem above this, dingbat")
- end
- serverId, status = init()
- if status then
- while true do
- main(serverId)
- end
- else
- error("Unknown error occured! Aborting...")
- end
Advertisement
Add Comment
Please, Sign In to add comment