Advertisement
Guest User

czat

a guest
Jan 19th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. rednet.open("back")
  4. local host_id = os.computerID()
  5. local uzyt = {}
  6. local uzyt_size = 0
  7. rednet.broadcast(host_id.." dolaczyl")
  8. rednet.broadcast("test", "test")
  9. print(host_id.." dolaczyl")
  10. while true do
  11.   param1, param2, param3, param4 = os.pullEvent()
  12.   if param1 == "rednet_message" and param3 == "test" and param4 == "test" then
  13.     rednet.send(param2, "T", "test")
  14.     local istnieje = false
  15.     for i=0,uzyt_size do
  16.       if uzyt[i] == param2 then
  17.         istnieje = true
  18.         break
  19.       end
  20.     end
  21.     if not istnieje then
  22.       uzyt[uzyt_size] = param2
  23.       uzyt_size = uzyt_size + 1
  24.     end
  25.   end
  26.   if param1 == "rednet_message" and param3 == "T" and param4 == "test" then
  27.     local istnieje = false
  28.     for i=0,uzyt_size do
  29.       if uzyt[i] == param2 then
  30.         local istnieje = true
  31.       end
  32.     end
  33.     if not istnieje then
  34.       uzyt[uzyt_size] = param2
  35.       uzyt_size = uzyt_size + 1
  36.       print("Na czacie znajduje sie "..param2)
  37.     end
  38.   end
  39.   if param1 == "rednet_message" then
  40.     print(param2.."- "..param3)
  41.   end
  42.   if param1 == "key" then
  43.     write("Twoja wiadomosc: ")
  44.     local mes = read()
  45.     if mes == "exit" then
  46.       rednet.broadcast(host_id.." wyszedl")
  47.       textutils.slowPrint("wychodze...")
  48.       rednet.close("back")
  49.       break
  50.     elseif mes == "list" then
  51.       write("Na czacie znajduja sie: ")
  52.       for i=0,uzyt_size-1 do
  53.         write(uzyt[i])
  54.       end
  55.       write("\n")
  56.     else
  57.       print(host_id.."- "..mes)
  58.       rednet.broadcast(mes)
  59.     end
  60.   end
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement