Advertisement
soulgriever

hub

Nov 27th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. --Load Charts API
  2. os.loadAPI("/apis/charts")
  3. os.loadAPI("/apis/ic2")
  4. os.loadAPI("/apis/tools")
  5. --Load Peripherals
  6. mon = peripheral.find("monitor")
  7. mon.setTextScale(1)
  8.  
  9. rednet.open("back")
  10. --Start Program
  11.  
  12. while true do
  13.  sleep(5)
  14.  local cell = {peripheral.find("mfsu")}
  15.  stored = ic2.getEUStored(cell)
  16.  capacity = ic2.getEUCapacity(cell)
  17.  charge = stored/capacity*100
  18.  local t = {}
  19.  t[0] = "Doc,Stored,Capacity,Charge"
  20.  t[1] = stored
  21.  t[2] = capacity
  22.  t[3] = tostring(tools.round(charge, 0))
  23.  term.redirect(mon)
  24.  tools.clear()
  25.  
  26.  if charge > 70 then
  27.   charts.lineColor("",2,5,16,stored,capacity,colors.green,colors.white,false)
  28.  end
  29.  if charge <= 70 and charge > 45 then
  30.   charts.lineColor("",2,5,16,stored,capacity,colors.yellow,colors.white,false)
  31.  end
  32.  if charge <= 45 then
  33.   charts.lineColor("",2,5,16,stored,capacity,colors.red,colors.white,false)
  34.  end
  35.  
  36.  local msg = textutils.serialize(t)
  37.  rednet.broadcast(msg, "EnergyStorage")
  38.  
  39.  tools.line(-13,-2)
  40.  term.write("MFSU Charge:")
  41.  tools.line(-9,3)
  42.  term.write(tostring(tools.round(charge, 0)))
  43.  term.write("%")
  44.  tools.line(-9,2)
  45.  term.write(tools.round(stored/1000000,1))
  46.  term.write("/")
  47.  term.write(tools.round(capacity/1000000, 1))
  48.  term.write(" MEU")
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement