Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while true do
- sleep(.1)
- local PeriList = peripheral.getNames()
- local TankList = {}
- local OtherPeriList = {}
- for i = 1, #PeriList do
- if string.match(PeriList[i],"rcirontankvalvetile") or string.match(PeriList[i],"rcsteeltankvalvetile") then
- TankList[#TankList + 1] = PeriList[i]
- else
- OtherPeriList[#OtherPeriList + 1] = PeriList[i]
- end
- end
- local Tank1 = peripheral.wrap(TankList[1])
- local Tank2 = peripheral.wrap(TankList[2])
- local Tank3 = peripheral.wrap(TankList[3])
- local Tank4 = peripheral.wrap(TankList[4])
- local DoubleArray1 = Tank1.getTankInfo("unknown")
- local SingleArray1 = DoubleArray1[1]
- local DoubleArray2 = Tank2.getTankInfo("unknown")
- local SingleArray2 = DoubleArray2[1]
- local DoubleArray3 = Tank3.getTankInfo("unknown")
- local SingleArray3 = DoubleArray3[1]
- local DoubleArray4 = Tank4.getTankInfo("unknown")
- local SingleArray4 = DoubleArray4[1]
- local percent1 = Percentage(SingleArray1["amount"], SingleArray1["capacity"])
- local percent2 = Percentage(SingleArray2["amount"], SingleArray2["capacity"])
- local percent3 = Percentage(SingleArray3["amount"], SingleArray3["capacity"])
- local percent4 = Percentage(SingleArray4["amount"], SingleArray4["capacity"])
- rednet.open("top")
- rednet.broadcast("Tank,"..SingleArray1["name"]..","..percent1..","..SingleArray2["name"]..","..percent2..","..SingleArray3["name"]..","..percent3..","..SingleArray4["name"]..","..percent4,"Monitor")
- rednet.close()
- end
- function Percentage(current,total)
- local No1 = current
- local No2 = total
- local Percent = (current / total) * 100
- return Round(Percent, 0)
- end
- function Round(num, idp)
- local mult = 10^(idp or 0)
- return math.floor(num * mult + 0.5) / mult
- end
Advertisement
Add Comment
Please, Sign In to add comment