09glich

MobileComs.lua

Jun 13th, 2024 (edited)
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.49 KB | None | 0 0
  1. local CompID = os.getComputerID
  2.  
  3. rednet.open(tostring(CompID))
  4.  
  5. local NearbyPingDB = 0
  6. local function PingForNearDevices()
  7.     NearbyPingDB = NearbyPingDB + 1
  8.     if NearbyPingDB > 5 then
  9.         rednet.broadcast(CompID)
  10.     end
  11.    
  12. end
  13.  
  14. local function Reping()
  15.     local ID, Message = rednet.receive(nil,.05)
  16.     if Message then
  17.         print(ID .. " : ".. Message)
  18.     end
  19.    
  20. end
  21.  
  22. while true do
  23.     --print("Looping")
  24.     sleep(.05)
  25.     PingForNearDevices()
  26.     Reping()
  27. end
Advertisement
Add Comment
Please, Sign In to add comment