melzneni

MonitorSendAdwanced

Jun 9th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. args={...}
  2. if #args<2 then
  3. error("required arguments: monitorName, senderName ")
  4. end
  5. mName=args[1]
  6. sName=args[2]
  7. rednet.open("back")
  8.  
  9. print("monitor: "..mName)
  10. print("sender: "..sName)
  11.  
  12. sidesAvailable={"left","right","top","bottom","front","back"}
  13.  
  14. storages={}
  15. c=0
  16. for i,side in pairs(sidesAvailable) do
  17. if peripheral.getType(side)=="IE:mvCapacitor" then
  18. storages[side]=peripheral.wrap(side)
  19. c=c+1
  20. print("found storage: "..side)
  21. end
  22. end
  23.  
  24. if c==0 then
  25. print("didn't find any storages")
  26. end
  27.  
  28. if c>0 then
  29. while true do
  30.  
  31. text="textToMonitor:"..mName..":"..sName..":"
  32. c=0
  33. for side,storage in pairs(storages) do
  34. if c==1 then
  35. text=text.."\n"
  36. end
  37. c=1
  38. text=text..side..":"..storage.getEnergyStored().."/"..storage.getMaxEnergyStored()
  39. end
  40.  
  41. rednet.broadcast(text,"monitoring")
  42.  
  43. sleep(1)
  44. end
  45. end
Add Comment
Please, Sign In to add comment