Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----Energy Cell Consumption Monitor--
- function cellVerify()
- while turtle.detect()==false do
- print("No cell detected")
- sleep(0.2)
- end
- print("Cell detected, resuming...")
- end
- function cellReplace()
- if turtle.dig()==true then print "Cell removed." end
- if turtle.dropUp()==true then print "Empty cell returned." end
- if turtle.suckDown()==true then print "New Cell Found." end
- if turtle.place()==true then print "Cell replaced." end
- cellVerify()
- end
- cell=peripheral.wrap("front")
- print (cell)
- modem=peripheral.wrap("right")
- if modem==true then
- rednet.open("right")
- end
- id=os.getComputerID()
- name=os.getComputerLabel()
- while true do
- cell=peripheral.wrap("front")
- if cell then
- print (cell)
- else
- print ("NO cell found")
- cellReplace()
- sleep(2)
- end
- ESlast=0
- while cell do
- term.clear()
- term.setCursorPos(1,1)
- print("----Energy Cell Consumption Monitor----")
- ES=tonumber(cell.getEnergyStored())
- print("Energy Stored: ".. ES)
- if ES<10 then
- print("Cell Empty, replacing...")
- cellReplace()
- end
- if ES>0 then
- used=ESlast-ES
- conS=tonumber(used/5)
- conT=tonumber(used/5)
- lclTbl= {cID=id, cName=name, pct=math.floor(ES/600000*100), cRate=conT}
- if modem==true then
- rednet.send(82, textutils.serialize(lclTbl))
- end
- -- ES, used, conT, conS}
- if used<0 then
- print("please wait while I get my first reading..." )
- else
- print("Computer: ".. id..", ".. name)
- for k,v in pairs(lclTbl) do
- print (k..".."..v)
- --print("Consumption: ".. conS .. "MJ/second (".. conT .. " MJ/tick)")
- end
- end
- ESlast=ES
- end
- used=0
- sleep(5)
- end
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement