Advertisement
Bmorr

bip_client.lua

Dec 27th, 2020
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. local protocol = "bip"
  2.  
  3. peripheral.find("modem", rednet.open)
  4. for _, val in ipairs(arg) do
  5.     term.setTextColor(colors.white)
  6.     print("\nRequesting "..val.."!")
  7.     rednet.broadcast(val, protocol)
  8.  
  9.     local id, pas, pro = rednet.receive(protocol, 5)
  10.    
  11.     local fname = val..".lua"
  12.     if fs.exists(fname) then
  13.         fs.delete(fname)
  14.     end
  15.     if pas ~= "unknown package" then
  16.         term.setTextColor(colors.green)
  17.         shell.run("pastebin get "..pas, fname)
  18.     else
  19.         term.setTextColor(colors.red)
  20.         print("Unkown package \""..val.."\"!")
  21.     end
  22. end
  23.  
  24. peripheral.find("modem", rednet.close)
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement