Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Modem Location
- modem = "back"
- --Load Functions API
- function getEUStored(cell)
- local count = 0
- for i = 1, #cell do
- count = count + cell[i].getEUStored()
- end
- return(count)
- end
- function getEUCapacity(cell)
- local count = 0
- for i = 1, #cell do
- count = count + cell[i].getEUCapacity()
- end
- return(count)
- end
- function round(num, numDecimalPlaces)
- local mult = 10^(numDecimalPlaces or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- --Load Peripherals
- rednet.open(modem)
- --Start Program
- while true do
- sleep(5)
- local cell = {peripheral.find("mfsu")}
- stored = getEUStored(cell)
- capacity = getEUCapacity(cell)
- charge = stored/capacity*100
- local t = {}
- t[0] = "Doc,Stored,Capacity,Charge"
- t[1] = stored
- t[2] = capacity
- t[3] = tostring(round(charge, 0))
- term.clear()
- term.setCursorPos(1,1)
- print(charge)
- local msg = textutils.serialize(t)
- rednet.broadcast(msg, "ME-MFSU")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement