Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local p = peripheral.wrap("left")
- if p == nil then
- error("Error : no tank found")
- end
- local mon = peripheral.find("monitor")
- if mon ~= nil then
- term.redirect(mon)
- end
- local function getTankInfos(tab, infos)
- for k,v in pairs(tab) do
- if type(v) ~= "table" then
- infos[k] = v
- else
- getTankInfos(v, infos)
- end
- end
- end
- local function printAllAtt(tab)
- for k,v in pairs(tab) do
- print(k)
- print(v)
- print("___")
- end
- end
- local function main()
- local tab = p.getTankInfo()
- local infos = {}
- getTankInfos(tab, infos)
- --printAllAtt(infos)
- --error()
- local capa = infos["capacity"]
- local am = infos["amount"]
- local percent
- if am < 0.1 then
- percent = 0
- else
- percent = am / capa * 100
- end
- if mon ~= nil then
- mon.clear()
- end
- print(infos["rawName"])
- print()
- print("Quantite :")
- print(tostring(am/1000) .. " b")
- print()
- print("Remplit a :")
- print(string.format("%.1f", percent) .. " %")
- end
- while true do
- main()
- sleep(10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement