LDShadowLord

SIRC V0.1

Oct 7th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. print("WARNING...")
  2. w,h = term.getSize()
  3.  
  4. lineno = 1
  5. rednet.open("back")
  6.  
  7. function listenForMessages()
  8.   while true do
  9.      local id, msg = rednet.receive()
  10.      if lineno == 16 then lineno = 1 end
  11.      local oldx,oldy = term.getCursorPos()
  12.      term.setCursorPos(1, lineno)
  13.      term.clearLine()
  14.      if string.find(msg, "::") then
  15.        term.write(string.gsub(msg, "::", ":"))
  16.      else
  17.        term.write(id..":"..msg)
  18.     end
  19.      term.setCursorPos(oldx, oldy)
  20.   end
  21.      lineno = lineno + 1
  22. end
  23.  
  24. function sendMessages()
  25.   term.setCursorPos(1, h-1)
  26.   while true do
  27.     message = io.read()
  28.     if message == "quit" then break end
  29.     rednet.broadcast(os.getComputerLabel().."::"..message)
  30.     term.setCursorPos(1, lineno)
  31.     term.write(os.getComputerLabel()..":"..message)
  32.     lineno = lineno + 1
  33.     term.setCursorPos(1, h-1)
  34.     term.clearLine()
  35.   end
  36. end
  37.  
  38. term.clear()
  39. term.setCursorPos(1, h-2)
  40. term.write(string.rep("*", w))
  41.  
  42. parallel.waitForAny(sendMessages,
  43.  listenForMessages)
Advertisement
Add Comment
Please, Sign In to add comment