Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------test zone---------------------
- local function getFluidList()
- local list = {
- { fluidName = "Water", fluidAmount = 64000, fluidCapacity = 64000 }, -- test fluid that is at 100% full
- { fluidName = "Latex", fluidAmount = 48000, fluidCapacity = 64000 }, -- test fluid that is at 75% full
- { fluidName = "Lava", fluidAmount = 64000, fluidCapacity = 128000 }, -- test fluid that is at 50% full
- { fluidName = "Steam", fluidAmount = 32000, fluidCapacity = 128000 }, -- test fluid that is at 25% full
- { fluidName = "Menril Resin", fluidAmount = 10000, fluidCapacity = 16000 }, -- test fluid with a long name
- { fluidName = "Molten Cobalt", fluidAmount = 42000, fluidCapacity = 69000 },-- test fluid with a long name
- { fluidName = "Liquid Hydrofloric Acid", fluidAmount = 42000, fluidCapacity = 69000 },-- test fluid with a even longer name
- { fluidName = "Liquid Uranium Hexaflorid", fluidAmount = 42000, fluidCapacity = 69000 },-- test fluid with a even longer name
- }
- return list
- end
- local fluidList = getFluidList()
- term.clear()
- term.setCursorPos(1,1)
- for i=1, #fluidList do
- local name = fluidList[i].fluidName
- local amount = fluidList[i].fluidAmount
- local capacity = fluidList[i].fluidCapacity
- print(name..": "..tostring(amount).."/"..tostring(capacity))
- end
- ----------- local variables ---------------------
- local mon = peripheral.find "monitor"
- local monName = peripheral.getName(mon)
- --monitor size--
- mon.setTextScale(0.5)
- local monX, monY = mon.getSize()
- ----------- Functions ---------------------
- function clear()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,1)
- end
- function draw_text(x, y, text, text_color, bg_color)
- mon.setBackgroundColor(bg_color)
- mon.setTextColor(text_color)
- mon.setCursorPos(x,y)
- mon.write(text)
- end
- function draw_line(x, y, length, color)
- mon.setBackgroundColor(color)
- mon.setCursorPos(x,y)
- mon.write(string.rep(" ", length))
- end
- function progress_bar(x, y, length, minVal, maxVal, bar_color, bg_color)
- draw_line(x, y, length, bg_color) --backgoround bar
- local barSize = math.floor((minVal/maxVal) * length)
- draw_line(x, y, barSize, bar_color) --progress so far
- end
- ------------------Fluid Level---------------------
- clear()
- local fluidList = getFluidList()
- draw_text(2, 2, "Fluid Monitoring System", colors.yellow, colors.black)
- for i=1, #fluidList do
- local name = fluidList[i].fluidName
- local amount = fluidList[i].fluidAmount
- local capacity = fluidList[i].fluidCapacity
- local percent = math.floor((amount/capacity)*100)
- draw_text(2, (3*i)+1, name, colors.yellow, colors.black)
- if percent < 100 then
- draw_text(monX-4, (3*i)+1, " "..percent.."%", colors.white, colors.black)
- else
- draw_text(monX-4, (3*i)+1, percent.."%", colors.white, colors.black)
- end
- if percent < 25 then
- progress_bar(2, (3*i)+2, monX-2, amount, capacity, colors.red, colors.gray)
- elseif percent < 50 then
- progress_bar(2, (3*i)+2, monX-2, amount, capacity, colors.orange, colors.gray)
- elseif percent < 75 then
- progress_bar(2, (3*i)+2, monX-2, amount, capacity, colors.yellow, colors.gray)
- elseif percent <= 100 then
- progress_bar(2, (3*i)+2, monX-2, amount, capacity, colors.lime, colors.gray)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment