MarkFergus

reseau/client

Jun 29th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rednet.open("back")
  2. local type = "spawner"
  3.  
  4. getIDs = function(arg)
  5.   if arg == type then return os.computerID() else
  6.     rednet.broadcast("getID",arg)
  7.     e = {rednet.receive(2)}
  8.   if e == "" then return "unindexed" else return e[1] end
  9.   end
  10. end
  11.  
  12. if fs.exists("/reseau/config") == false then file = fs.open("reseau/config","w") file.write({
  13. server_id = getIDs("server"),
  14. spawner_id = getIDs("spawner"),
  15. energy_id = getIDs("energy"),
  16. })
  17. file.close() end
  18. f1 = fs.open("/reseau/config","r") index = textutils.unserialise(f1.readAll()) f1.close()
  19. print(index["server_id"])
  20.  
  21. while true do
  22.   e = {rednet.receive()}
  23.   print(textutils.serialise(e))
  24.   if e[2] == "getID" then
  25.     if e[3] == type then rednet.broadcast() end
  26.   end
  27.   if e[1] == index.server_id and e[2] == type then
  28.     if e[3] == "periphs" then rednet.send(e[1],peripheral.getNames()) end
  29.   end
  30. end
Add Comment
Please, Sign In to add comment