Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local upper = 0.90 --Upper limit for computer to stop transmitting redstone signal. 0.90=90% full.
- local lower = 0.10 --Lower limit for computer to start transmitting redstone signal.
- -------------------FORMATTING-------------------------------
- function clear()
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- monitor.setCursorPos(1,1)
- end
- function draw_text_term(x, y, text, text_color, bg_color)
- term.setTextColor(text_color)
- term.setBackgroundColor(bg_color)
- term.setCursorPos(x,y)
- write(text)
- end
- function draw_text(x, y, text, text_color, bg_color)
- monitor.setBackgroundColor(bg_color)
- monitor.setTextColor(text_color)
- monitor.setCursorPos(x,y)
- monitor.write(text)
- end
- function draw_line(x, y, length, color)
- monitor.setBackgroundColor(color)
- monitor.setCursorPos(x,y)
- monitor.write(string.rep(" ", length))
- end
- function draw_line_term(x, y, length, color)
- term.setBackgroundColor(color)
- term.setCursorPos(x,y)
- term.write(string.rep(" ", length))
- end
- function progress_bar(x, y, length, minVal, eMax, bar_color, bg_color)
- draw_line(x, y, length, bg_color) --backgoround bar
- local barSize = math.floor((eNow/eMax) * length)
- draw_line(x, y, barSize, bar_color) --progress so far
- end
- function progress_bar_term(x, y, length, eNow, eMax, bar_color, bg_color)
- draw_line_term(x, y, length, bg_color) --backgoround bar
- local barSize = math.floor((eNow/eMax) * length)
- draw_line_term(x, y, barSize, bar_color) --progress so far
- end
- -------Device detection--------------
- isError=0
- function detectDevice(DeviceName)
- DeviceSide="none"
- for k,v in pairs(redstone.getSides()) do
- if peripheral.getType(v)==DeviceName then
- DeviceSide = v
- break
- end
- end
- return(DeviceSide)
- end
- -------Wrap Peripheral--------------
- power="none"
- monitor="none"
- local peripheralList = peripheral.getNames()
- powerSide=detectDevice("power_storage")
- if powerSide~="none" then
- power=peripheral.wrap(powerSide)
- print ("Power monitor " .. powerSide .. " connected.")
- else
- powerSide=detectDevice("tile_enderio_blockcapacitorbank_name")
- if powerSide~="none" then
- power=peripheral.wrap(powerSide)
- print ("EnderIO capacitorbank on the " .. powerSide .. " connected.")
- else
- for Index = 1, #peripheralList do
- if string.find(peripheralList[Index], "power_storage") then
- power=peripheral.wrap(peripheralList[Index])
- print ("Power Monitor on wired modem: "..peripheralList[Index].." connected.")
- elseif string.find(peripheralList[Index], "tile_enderio_blockcapacitorbank_name") then
- power=peripheral.wrap(peripheralList[Index])
- print ("EnderIO capacitorbank on wired modem: "..peripheralList[Index].." connected.")
- end
- end --for
- if power == "none" then
- print("No Energy storage found. Halting script!")
- return
- end
- end
- end
- -------Monitor Connect--------------
- MonitorSide=detectDevice("monitor")
- if MonitorSide~="none" then
- monitor=peripheral.wrap(MonitorSide)
- print ("Monitor on the " .. MonitorSide .. " connected.")
- else
- for Index = 1, #peripheralList do
- if string.find(peripheralList[Index], "monitor") then
- monitor=peripheral.wrap(peripheralList[Index])
- print ("Monitor on wired modem: "..peripheralList[Index].." connected.")
- end
- end --for
- if monitor == "none" then
- print ("Warning - No Monitor attached, continuing without.")
- end
- end
- -------Monitor write functions--------------
- function homepage()
- while true do
- clear()
- menu_bar()
- terminal_screen()
- -------Monitor write text--------------
- if monitor ~= "none" then
- draw_text(2, 2, "Fuel Level:", colors.yellow, colors.black)
- local eMax = power.getMaxPowerInMachines()
- local eNow = power.getPowerInMachines()
- local percent = ((eNow/eMax)*100)
- draw_text(15, 5, percent.."%", colors.white, colors.black)
- if percent < 25 then
- progress_bar(2, 4, monX-2, eNow, eMax, colors.red, colors.gray)
- else if percent < 50 then
- progress_bar(2, 4, monX-2, eNow, eMax, colors.orange, colors.gray)
- else if percent < 75 then
- progress_bar(2, 4, monX-2, eNow, eMax, colors.yellow, colors.gray)
- else if percent < 100 then
- progress_bar(2, 4, monX-2, eNow, eMax, colors.lime, colors.gray)
- end
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement