Advertisement
Guest User

chat

a guest
May 22nd, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.57 KB | None | 0 0
  1. rednet.open("top")
  2. mon = peripheral.wrap("left")
  3. term.clear()
  4. mon.clear()
  5. term.setCursorPos(16,2)
  6. mon.setCursorPos(9,1)
  7. term.setTextColor(32)
  8. mon.setTextColor(32)
  9. print("Welcome in global chat")
  10. mon.write("Welcome in glogal chat")
  11. term.setCursorPos(11,3)
  12. mon.setCursorPos(3,2)
  13. print("Click to speak and press e to left")
  14. mon.write("Click to speak and presse e to left")
  15. term.setTextColor(1)
  16. mon.setTextColor(1)
  17. while true do
  18.   local event, param1, message = os.pullEvent()
  19.     if event == "mouse_click" then
  20.     term.setCursorPos(3,15)
  21.     mon.setCursorPos(3,12)
  22.     term.setTextColor(8)
  23.     mon.setTextColor(8)
  24.     write("#1 : ")
  25.     local msg = read()
  26.     mon.write("#1 : "..msg)
  27.     rednet.broadcast(msg)
  28.     term.scroll(1)
  29.     mon.scroll(1)
  30.     term.setCursorPos(3,15)
  31.     mon.setCursorPos(3,12)
  32.     term.setTextColor(1)
  33.     mon.setTextColor(1)
  34.   end
  35.   if event == "rednet_message" then
  36.     term.setCursorPos(3,15)
  37.     mon.setCursorPos(3,12)
  38.     if message == "   ooO #2 has disconected Ooo   " then
  39.       term.setTextColor(16384)
  40.       mon.setTextColor(16384)
  41.       write(message)
  42.       mon.write(message)
  43.       term.setTextColor(1)
  44.       mon.setTextColor(1)
  45.       term.scroll(1)
  46.       mon.scroll(1)
  47.       term.setCursorPos(3,15)
  48.       mon.setCursorPos(3,12)
  49.     else
  50.       term.setTextColor(4)
  51.       mon.setTextColor(4)
  52.       write("#2 : "..message)
  53.       mon.write("#2 : "..message)
  54.       term.scroll(1)
  55.       mon.scroll(1)
  56.       term.setCursorPos(3,15)
  57.       mon.setCursorPos(3,12)
  58.       term.setTextColor(1)
  59.       mon.setTextColor(1)
  60.     end
  61.   end
  62.   if event == "key" and param1 == 18 then
  63.     term.setTextColor(16384)
  64.     mon.setTextColor(16384)
  65.     term.setCursorPos(13,4)
  66.     mon.setCursorPos(9,3)
  67.     print("Do you really want to quit")
  68.     mon.write("Do you really want to quit ?")
  69.     term.setCursorPos(15,5)
  70.     mon.setCursorPos(11,4)
  71.     print("[ENTER] yes   [SUPPR] no")
  72.     mon.write("[ENTER] yes   [SUPPR] no")    
  73.     local event, touche = os.pullEvent("key")
  74.     if touche == 28 then
  75.       rednet.broadcast("   ooO #2 has disconected Ooo   ")
  76.       term.setCursorPos(15,7)
  77.       mon.setCursorPos(12,6)
  78.       term.setTextColor(2)
  79.       mon.setTextColor(2)
  80.       write("Disconecting .")
  81.       mon.write("Disconecting .")
  82.       sleep(0.5)
  83.       write(".")
  84.       mon.write(".")
  85.       sleep(0.25)
  86.       write(".")
  87.       mon.write(".")
  88.       sleep(0.25)
  89.       mon.clear()
  90.       term.setTextColor(1)
  91.       mon.setTextColor(2)
  92.       os.reboot()
  93.     elseif touche == 211 then
  94.       shell.run("chat")
  95.     end
  96.   end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement