Advertisement
Guest User

czat

a guest
Jan 19th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. term.clear()
  2. term.getCursorPos(1, 1)
  3. rednet.open("back")
  4. local host_id = os.computerID()
  5. rednet.broadcast(host_id.." dolaczyl do czatu")
  6. print(host_id.." dolaczyl do czatu, napisz 'exit' aby wyjsc")
  7. while true do
  8.   sender_id, mess_in = rednet.receive("", 1)
  9.   if mess_in ~= nil then
  10.     textutils.slowPrint(sender_id.."- "..mess_in)
  11.   end
  12.   local event, key, isHeld = os.pullEvent("key")
  13.   if keys.getName(key) ~= nil then
  14.     write("Wyslij swoja wiadomosc: ")
  15.     local mesydz = read()
  16.     if mesydz == "exit" then
  17.       rednet.broadcast(host_id.." opuscil czat")
  18.       textutils.slowPrint(host_id.." opuscil czat")
  19.       rednet.close("back")
  20.       break
  21.     end
  22.     rednet.broadcast(host_id.."- "..mesydz)
  23.     print(host_id.."- "..mesydz)
  24.   end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement