Advertisement
Tatantyler

Test IRC Client

Sep 22nd, 2012
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. for i,v in ipairs(rs.getSides()) do
  2.     if peripheral.getType(v) == "modem" then
  3.         rednet.open(v)
  4.         break
  5.     end
  6. end
  7.  
  8. print("Username:")
  9.  
  10. local user = read()
  11.  
  12. local lines = {}
  13.  
  14. local function getRednetInput()
  15.     id, msg = rednet.receive()
  16.     msg = textutils.unserialize(msg)
  17.     if type(msg) == "table" then
  18.         print("["..msg[1].."] "..msg[2])
  19.     end
  20. end
  21.  
  22. local function broadcastMessages()
  23.     local line = read()
  24.     local packet = {}
  25.     table.insert(packet, user)
  26.     table.insert(packet, line)
  27.     rednet.broadcast(textutils.serialize(packet))
  28. end
  29.  
  30. while true do
  31.     parallel.waitForAny(getRednetInput, broadcastMessages)
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement