Advertisement
Guest User

startup

a guest
Feb 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. p = {}
  2. rednet.open("right")
  3. local x = {peripheral.find("EnergyMeterRF")}
  4. print(x)
  5.  
  6. for k,v in  pairs(x) do
  7.     p[v.getLabel()] = v
  8. end
  9.  
  10. function loadDB()
  11.   local f = fs.open("db", "r")
  12.   db = textutils.unserialize(f.readAll())
  13.   f.close()
  14. end
  15.  
  16. function saveDB()
  17.   local f = fs.open("db", "w")
  18.   f.write(textutils.serialize(db))
  19.   f.close()
  20. end
  21.  
  22. while true do
  23.     e = {}
  24.     for k,v in pairs(p) do
  25.         if not v.isOutputAllowed() then
  26.             e[k] = -1
  27.             v.reset()
  28. print("out")
  29. print(v)
  30.         else       
  31.             e[k] = v.getCountAndReset()
  32.         end
  33.     end
  34.     rednet.send(33, textutils.serialize(e))
  35.  rednet.send(34, textutils.serialise(e))
  36.     os.sleep(1)
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement