Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local warn = 20 --Set Warning Level of Fluids at this percentage
- local d = peripheral.wrap("monitor_0")
- local gap = 2
- local background = colors.white
- local foreground = colors.green
- local tanks = {}
- local fluids = {}
- d.setTextScale(1)
- d.setBackgroundColor(colors.black)
- for _, name in pairs(peripheral.getNames()) do
- if peripheral.getType(name) == "rcirontankvalvetile" then
- table.insert(tanks, name)
- elseif peripheral.getType(name) == "rcsteeltankvalvetile" then
- table.insert(tanks, name)
- end
- end
- function cwrite(text)
- local w, h = d.getSize()
- local x, y = d.getCursorPos()
- --x = math.max(math.floor((w/2) - (#text / 2)), 0)
- term.setCursorPos(x,y)
- print(text)
- --term.setCursorPos(x,y+1)
- end
- function getinfo()
- for k,v in pairs(tanks) do
- tank = peripheral.wrap(v)
- info = tank.getTankInfo(v)
- for k,fluid in pairs(info) do
- if fluid["rawName"] == nil then
- else
- if fluid["capacity"] > 1000 then
- tankcap = fluid["capacity"]
- end
- tankamt = fluid["amount"]
- name = fluid["name"]
- if name == "honey" then
- name = "Honey"
- elseif name == "bioethanol" then
- name = "Ethanol"
- elseif name == "liquiddna" then
- name = "BNA"
- elseif string.sub(name, -7) == ".molten" then
- name = string.upper(string.sub(name,0,1))..string.sub(name,2,-8)
- end
- fluids[name] = {["cap"] = tankcap, ["amt"] = tankamt}
- end
- end
- end
- end
- while true do
- term.clear()
- d.clear()
- term.setCursorPos(1,1)
- d.setCursorPos(2,1)
- maxx, maxy = d.getSize()
- local maxv = maxy-1
- getinfo()
- for key,val in pairs(fluids) do
- currx, curry = d.getCursorPos()
- d.setCursorPos(currx, maxv)
- cap = val["cap"]
- amt = val["amt"]
- prcnt = amt/cap*100
- prcnt = math.floor(prcnt)
- if prcnt < warn then
- term.setTextColor(colors.red)
- else
- term.setTextColor(colors.white)
- end
- print(key..": "..prcnt.."%")
- term.setTextColor(colors.white)
- term.redirect(d)
- currval = math.ceil(((maxv)*prcnt)/100)
- i = 1
- while i == 1 do
- d.setTextColor(colors.white)
- currx, curry = d.getCursorPos()
- str = tostring(prcnt.."%")
- x = math.max(math.floor((#key/2) - (#str / 2) + currx), 0)
- d.setCursorPos(x, curry)
- d.write(prcnt.."%")
- d.setCursorPos(currx, curry-1)
- d.write(key..":")
- d.setCursorPos(currx, curry-2)
- i=i+2
- end
- while i < currval do
- d.setBackgroundColor(foreground)
- d.setTextColor(foreground)
- currx, curry = d.getCursorPos()
- d.write(key)
- d.setCursorPos(currx, curry-1)
- i=i+1
- end
- while i < maxv do
- d.setBackgroundColor(background)
- d.setTextColor(background)
- currx, curry = d.getCursorPos()
- d.write(key)
- d.setCursorPos(currx, curry-1)
- i=i+1
- end
- d.setBackgroundColor(colors.black)
- currx, curry = d.getCursorPos()
- d.setCursorPos(currx + #key + gap, maxv)
- term.restore()
- end
- sleep(1.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement