Maschini

inv_sub

Feb 28th, 2023
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. local protocol = "inventory_main"
  2. local hostname = "c1"
  3.  
  4. rednet.open("top")
  5. local inventories = {}
  6.  
  7. local names = peripheral.getNames()
  8. for _, name in pairs(names) do
  9.   if peripheral.hasType(name, "inventory") then
  10.     print("found inventory:", name)
  11.     table.insert(inventories, peripheral.wrap(name))
  12.   end
  13. end
  14.  
  15.  
  16.  
  17.  
  18. while true do
  19.   local computers = {rednet.lookup(protocol)}
  20.   for _, computer in pairs(computers) do
  21.     for i, value in pairs(inventories) do
  22.       local message = {
  23.         id=computer,
  24.         name=i,
  25.         data=value.list()
  26.       }
  27.       rednet.send(computer, message, protocol)
  28.     end
  29.  
  30.     for i = 1, 10, 1 do
  31.       rednet.send(computer, "test", "turtle")
  32.       sleep(0.1)
  33.     end
  34.   end
  35.  
  36.  
  37.  
  38.   sleep(1)
  39.   --local id, message = rednet.receive(protocol)
  40.   --print(id, message)
  41. end
Advertisement
Add Comment
Please, Sign In to add comment