Advertisement
Guest User

plusChat

a guest
Apr 23rd, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. id = 35
  2.  
  3. --[Functions]--
  4. function draw()
  5.   term.setCursorPos(1,17)
  6.   term.setBackgroundColor(colors.gray)
  7.   term.clearLine()
  8.   term.setBackgroundColor(colors.black)
  9.   term.setCursorPos(1,16)
  10.   term.clearLine()
  11. end
  12.  
  13. local nick = read()
  14. --rednet.send(31,nick..": "..read())
  15. --local id, msg, dst = rednet.receive()
  16. --print(msg)
  17.  
  18. function event()
  19.   local event, a, b, c = os.pullEventRaw()
  20.   if event == "mouse_click" and c == 17 then
  21.     term.setCursorPos(2,17)
  22.     term.setBackgroundColor(colors.gray)
  23.     local msg = read()
  24.     rednet.send(id,nick..": "..msg)
  25.     term.setBackgroundColor(colors.black)
  26.     draw()
  27.   elseif event == "rednet_message" then
  28.     term.scroll(1)
  29.     draw()
  30.     term.setCursorPos(2,14)
  31.     term.write(b)
  32.   elseif event == "terminate" then
  33.     rednet.send(id,"Server: "..nick.." has left the chat")
  34.     os.reboot()
  35.   end
  36. end
  37.  
  38. --[Code]--
  39.  
  40. rednet.open("right")
  41. term.clear()
  42. draw()
  43. rednet.send(id,"Server: "..nick.." has joined the chat")
  44. while true do
  45.   event()
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement