Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("monitor_138")
- local core = peripheral.wrap("draconic_rf_storage_13")
- local gateBlock1 = peripheral.wrap("flux_gate_65")
- local gateBlock2 = peripheral.wrap("flux_gate_63")
- local gateBlock3 = peripheral.wrap("flux_gate_61")
- local gateBlock4 = peripheral.wrap("flux_gate_64")
- local gateBlock5 = peripheral.wrap("flux_gate_62")
- local gateBlock6 = peripheral.wrap("flux_gate_60")
- local gateExtra = peripheral.wrap("flux_gate_67")
- local gateRecl = peripheral.wrap("flux_gate_68")
- local gateRepl = peripheral.wrap("flux_gate_69")
- local mon, monX, monY
- monX, monY = monitor.getSize()
- mon = {}
- mon.monitor,mon.X, mon.Y = monitor, monX, monY
- function clear(mon)
- term.clear()
- term.setCursorPos(1,1)
- mon.monitor.setBackgroundColor(colors.black)
- mon.monitor.clear()
- mon.monitor.setCursorPos(1,1)
- end
- function draw_text(mon, x, y, text, text_color, bg_color)
- mon.monitor.setBackgroundColor(bg_color)
- mon.monitor.setTextColor(text_color)
- mon.monitor.setCursorPos(x,y)
- mon.monitor.write(text)
- end
- function draw_text_right(mon, offset, y, text, text_color, bg_color)
- mon.monitor.setBackgroundColor(bg_color)
- mon.monitor.setTextColor(text_color)
- mon.monitor.setCursorPos(mon.X-string.len(tostring(text))-offset,y)
- mon.monitor.write(text)
- end
- function draw_text_lr(mon, x, y, offset, text1, text2, text1_color, text2_color, bg_color)
- draw_text(mon, x, y, text1, text1_color, bg_color)
- draw_text_right(mon, offset, y, text2, text2_color, bg_color)
- end
- function draw_line(mon, x, y, length, color)
- if length < 0 then
- length = 0
- end
- mon.monitor.setBackgroundColor(color)
- mon.monitor.setCursorPos(x,y)
- mon.monitor.write(string.rep(" ", length))
- end
- function progress_bar(mon, x, y, length, minVal, maxVal, bar_color, bg_color)
- draw_line(mon, x, y, length, bg_color)
- local barSize = math.floor((minVal/maxVal) * length)
- draw_line(mon, x, y, barSize, bar_color)
- end
- function format_int(number)
- if number == nil then number = 0 end
- local i, j, minus, int, fraction = tostring(number):find('([-]?)(%d+)([.]?%d*)')
- int = int:reverse():gsub("(%d%d%d)", "%1,")
- return minus .. int:reverse():gsub("^,", "") .. fraction
- end
- local blockTweak = 1
- function save_config()
- sw = fs.open("config.txt", "w")
- sw.writeLine(blockTweak)
- sw.close()
- end
- function load_config()
- sr = fs.open("config.txt", "r")
- blockTweak = tonumber(sr.readLine())
- sr.close()
- end
- if fs.exists("config.txt") == false then
- save_config()
- else
- load_config()
- end
- local eFlowOption = 0
- function buttons()
- while true do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- if yPos == 18 then
- local cFlow = gateExtra.getSignalLowFlow()
- if xPos >= 2 and xPos <= 4 then cFlow = cFlow-10000
- elseif xPos >= 6 and xPos <= 8 then cFlow = cFlow-100000
- elseif xPos >= 10 and xPos <= 12 then cFlow = cFlow-1000000
- elseif xPos >= 18 and xPos <= 20 then cFlow = cFlow+1000000
- elseif xPos >= 22 and xPos <= 24 then cFlow = cFlow+100000
- elseif xPos >= 26 and xPos <= 28 then cFlow = cFlow+10000
- end
- gateExtra.setSignalLowFlow(cFlow)
- end
- if yPos == 6 and xPos == 28 then
- if eFlowOption == 1 then
- eFlowOption = 0
- else
- eFlowOption = 1
- end
- end
- if yPos == 9 and (xPos == 27 or xPos == 28) then
- if blockTweak == 1 then
- blockTweak = 0
- else
- blockTweak = 1
- end
- end
- if blockTweak == 0 then
- if (xPos >= 7 and xPos <= 9) and yPos == 10 then
- if gateBlock1.getSignalLowFlow() > 0 then
- gateBlock1.setSignalLowFlow(0)
- else
- gateBlock1.setSignalLowFlow(6000000)
- end
- end
- if (xPos >= 7 and xPos <= 9) and yPos == 12 then
- if gateBlock2.getSignalLowFlow() > 0 then
- gateBlock2.setSignalLowFlow(0)
- else
- gateBlock2.setSignalLowFlow(6000000)
- end
- end
- if (xPos >= 7 and xPos <= 9) and yPos == 14 then
- if gateBlock3.getSignalLowFlow() > 0 then
- gateBlock3.setSignalLowFlow(0)
- else
- gateBlock3.setSignalLowFlow(6000000)
- end
- end
- if (xPos >= 16 and xPos <= 18) and yPos == 10 then
- if gateBlock4.getSignalLowFlow() > 0 then
- gateBlock4.setSignalLowFlow(0)
- else
- gateBlock4.setSignalLowFlow(6000000)
- end
- end
- if (xPos >= 16 and xPos <= 18) and yPos == 12 then
- if gateBlock5.getSignalLowFlow() > 0 then
- gateBlock5.setSignalLowFlow(0)
- else
- gateBlock5.setSignalLowFlow(6000000)
- end
- end
- if (xPos >= 16 and xPos <= 18) and yPos == 14 then
- if gateBlock6.getSignalLowFlow() > 0 then
- gateBlock6.setSignalLowFlow(0)
- else
- gateBlock6.setSignalLowFlow(6000000)
- end
- end
- if (xPos >= 25 and xPos <= 27) and yPos == 10 then
- if gateRecl.getSignalLowFlow() > 0 then
- gateRecl.setSignalLowFlow(0)
- else
- gateRecl.setSignalLowFlow(6000000)
- end
- end
- if (xPos >= 25 and xPos <= 27) and yPos == 12 then
- if gateRepl.getSignalLowFlow() > 0 then
- gateRepl.setSignalLowFlow(0)
- else
- gateRepl.setSignalLowFlow(6000000)
- end
- end
- end
- end
- end
- function drawButtons(y)
- draw_text(mon, 2, y, " <", colors.white, colors.gray)
- draw_text(mon, 6, y, " <<", colors.white, colors.gray)
- draw_text(mon, 10, y, "<<<", colors.white, colors.gray)
- draw_text(mon, 18, y, ">>>", colors.white, colors.gray)
- draw_text(mon, 22, y, ">> ", colors.white, colors.gray)
- draw_text(mon, 26, y, "> ", colors.white, colors.gray)
- end
- local eMax
- local eNow
- local ePercent
- local eLast = 0
- local eFlow
- function update()
- while true do
- clear(mon)
- eMax = core.getMaxEnergyStored()
- eNow = core.getEnergyStored()
- ePercent = (math.floor(eNow/eMax*10000))/100
- eFlow = math.floor((eNow-eLast)/2)
- eLast = eNow
- -- terminal display
- print(" Capacity: " .. eMax .. " rf")
- print(" Energy: " .. eNow .. " rf ... " .. ePercent .. " %")
- print()
- if (eFlow > 0) then
- print("Avg. flow: +" .. eFlow .. " rf/t")
- else
- print("Avg. flow: " .. eFlow .. " rf/t")
- end
- print()
- -- monitor display
- draw_text_lr(mon, 2, 2, 0, "Main Energy Core", "Tier 7", colors.lightBlue, colors.blue, colors.black)
- local energyColor
- if ePercent >= 75 then energyColor = colors.orange end
- if ePercent < 75 and ePercent >= 50 then energyColor = colors.red end
- if ePercent < 50 and ePercent >= 25 then energyColor = colors.purple end
- if ePercent < 25 then energyColor = colors.cyan end
- if eNow >= 1000000000000 then
- draw_text_lr(mon, 2, 4, 0, format_int((math.floor(eNow/1000000000))/1000) .. " T rf", ePercent .. " %", colors.lightGray, energyColor, colors.black)
- elseif eNow < 1000000000000 and eNow >= 1000000000 then
- draw_text_lr(mon, 2, 4, 0, format_int((math.floor(eNow/1000000))/1000) .. " B rf", ePercent .. " %", colors.lightGray, energyColor, colors.black)
- elseif eNow < 1000000000 and eNow >= 1000000 then
- draw_text_lr(mon, 2, 4, 0, format_int((math.floor(eNow/1000))/1000) .. " M rf", ePercent .. " %", colors.lightGray, energyColor, colors.black)
- else
- draw_text_lr(mon, 2, 4, 0, format_int(eNow) .. " rf", ePercent .. " %", colors.lightGray, energyColor, colors.black)
- end
- progress_bar(mon, 2, 5, mon.X-2, ePercent, 100, energyColor, colors.gray)
- draw_text(mon, 28, 6, "*", colors.gray, colors.black)
- if eFlowOption == 1 then
- draw_text_right(mon, 0, 6, format_int(eFlow) .. " *", colors.gray, colors.black)
- end
- local energyUpDown
- if eFlow > 0 then energyUpDown = colors.lime end
- if eFlow == 0 then energyUpDown = colors.gray end
- if eFlow < 0 then energyUpDown = colors.red end
- if eFlow >= math.abs(1000000000) then
- if eFlow > 0 then
- draw_text_lr(mon, 2, 7, 0, "Energy Flow", "+" .. format_int((math.floor(eFlow/1000000))/1000) .. " B rf/t", colors.white, energyUpDown, colors.black)
- else
- draw_text_lr(mon, 2, 7, 0, "Energy Flow", format_int((math.floor(eFlow/1000000))/1000) .. " B rf/t", colors.white, energyUpDown, colors.black)
- end
- elseif eFlow < math.abs(1000000000) and eFlow >= math.abs(1000000) then
- if eFlow > 0 then
- draw_text_lr(mon, 2, 7, 0, "Energy Flow", "+" .. format_int((math.floor(eFlow/1000))/1000) .. " M rf/t", colors.white, energyUpDown, colors.black)
- else
- draw_text_lr(mon, 2, 7, 0, "Energy Flow", format_int((math.floor(eFlow/1000))/1000) .. " M rf/t", colors.white, energyUpDown, colors.black)
- end
- else
- if eFlow > 0 then
- draw_text_lr(mon, 2, 7, 0, "Energy Flow", "+" .. format_int(eFlow) .. " rf/t", colors.white, energyUpDown, colors.black)
- else
- draw_text_lr(mon, 2, 7, 0, "Energy Flow", format_int(eFlow) .. " rf/t", colors.white, energyUpDown, colors.black)
- end
- end
- draw_text(mon, 2, 9, "UU Blocks Power control", colors.purple, colors.black)
- draw_text(mon, 3, 10, "UU1 ", colors.white, colors.gray)
- draw_text(mon, 3, 12, "UU2 ", colors.white, colors.gray)
- draw_text(mon, 3, 14, "UU3 ", colors.white, colors.gray)
- draw_text(mon, 12, 10, "UU4 ", colors.white, colors.gray)
- draw_text(mon, 12, 12, "UU5 ", colors.white, colors.gray)
- draw_text(mon, 12, 14, "UU6 ", colors.white, colors.gray)
- draw_text(mon, 21, 10, "RCC ", colors.white, colors.gray)
- draw_text(mon, 21, 12, "RPL ", colors.white, colors.gray)
- if blockTweak == 1 then
- draw_text_right(mon, 0, 9, "AU", colors.white, colors.gray)
- if ePercent > 45 then gateRepl.setSignalLowFlow(6000000) end
- if ePercent > 50 then gateRecl.setSignalLowFlow(6000000) end
- if ePercent > 55 then gateBlock1.setSignalLowFlow(6000000) end
- if ePercent > 60 then gateBlock2.setSignalLowFlow(6000000) end
- if ePercent > 65 then gateBlock3.setSignalLowFlow(6000000) end
- if ePercent > 70 then gateBlock4.setSignalLowFlow(6000000) end
- if ePercent > 75 then gateBlock5.setSignalLowFlow(6000000) end
- if ePercent > 80 then gateBlock6.setSignalLowFlow(6000000) end
- if ePercent < 40 then gateRepl.setSignalLowFlow(0) end
- if ePercent < 45 then gateRecl.setSignalLowFlow(0) end
- if ePercent < 50 then gateBlock1.setSignalLowFlow(0) end
- if ePercent < 55 then gateBlock2.setSignalLowFlow(0) end
- if ePercent < 60 then gateBlock3.setSignalLowFlow(0) end
- if ePercent < 65 then gateBlock4.setSignalLowFlow(0) end
- if ePercent < 70 then gateBlock5.setSignalLowFlow(0) end
- if ePercent < 75 then gateBlock6.setSignalLowFlow(0) end
- if gateRepl.getSignalLowFlow() > 0 then
- draw_text(mon, 25, 12, " ON", colors.lime, colors.gray)
- else
- draw_text(mon, 25, 12, "OFF", colors.red, colors.gray)
- end
- if gateRecl.getSignalLowFlow() > 0 then
- draw_text(mon, 25, 10, " ON", colors.lime, colors.gray)
- else
- draw_text(mon, 25, 10, "OFF", colors.red, colors.gray)
- end
- if gateBlock1.getSignalLowFlow() > 0 then
- draw_text(mon, 7, 10, " ON", colors.lime, colors.gray)
- else
- draw_text(mon, 7, 10, "OFF", colors.red, colors.gray)
- end
- if gateBlock2.getSignalLowFlow() > 0 then
- draw_text(mon, 7, 12, " ON", colors.lime, colors.gray)
- else
- draw_text(mon, 7, 12, "OFF", colors.red, colors.gray)
- end
- if gateBlock3.getSignalLowFlow() > 0 then
- draw_text(mon, 7, 14, " ON", colors.lime, colors.gray)
- else
- draw_text(mon, 7, 14, "OFF", colors.red, colors.gray)
- end
- if gateBlock4.getSignalLowFlow() > 0 then
- draw_text(mon, 16, 10, " ON", colors.lime, colors.gray)
- else
- draw_text(mon, 16, 10, "OFF", colors.red, colors.gray)
- end
- if gateBlock5.getSignalLowFlow() > 0 then
- draw_text(mon, 16, 12, " ON", colors.lime, colors.gray)
- else
- draw_text(mon, 16, 12, "OFF", colors.red, colors.gray)
- end
- if gateBlock6.getSignalLowFlow() > 0 then
- draw_text(mon, 16, 14, " ON", colors.lime, colors.gray)
- else
- draw_text(mon, 16, 14, "OFF", colors.red, colors.gray)
- end
- else
- draw_text_right(mon, 0, 9, "MA", colors.white, colors.gray)
- if gateRepl.getSignalLowFlow() > 0 then
- draw_text(mon, 25, 12, " ON", colors.white, colors.green)
- else
- draw_text(mon, 25, 12, "OFF", colors.white, colors.red)
- end
- if gateRecl.getSignalLowFlow() > 0 then
- draw_text(mon, 25, 10, " ON", colors.white, colors.green)
- else
- draw_text(mon, 25, 10, "OFF", colors.white, colors.red)
- end
- if gateBlock1.getSignalLowFlow() > 0 then
- draw_text(mon, 7, 10, " ON", colors.white, colors.green)
- else
- draw_text(mon, 7, 10, "OFF", colors.white, colors.red)
- end
- if gateBlock2.getSignalLowFlow() > 0 then
- draw_text(mon, 7, 12, " ON", colors.white, colors.green)
- else
- draw_text(mon, 7, 12, "OFF", colors.white, colors.red)
- end
- if gateBlock3.getSignalLowFlow() > 0 then
- draw_text(mon, 7, 14, " ON", colors.white, colors.green)
- else
- draw_text(mon, 7, 14, "OFF", colors.white, colors.red)
- end
- if gateBlock4.getSignalLowFlow() > 0 then
- draw_text(mon, 16, 10, " ON", colors.white, colors.green)
- else
- draw_text(mon, 16, 10, "OFF", colors.white, colors.red)
- end
- if gateBlock5.getSignalLowFlow() > 0 then
- draw_text(mon, 16, 12, " ON", colors.white, colors.green)
- else
- draw_text(mon, 16, 12, "OFF", colors.white, colors.red)
- end
- if gateBlock6.getSignalLowFlow() > 0 then
- draw_text(mon, 16, 14, " ON", colors.white, colors.green)
- else
- draw_text(mon, 16, 14, "OFF", colors.white, colors.red)
- end
- end
- draw_text(mon, 2, 16, "Energy ExtraOUT", colors.yellow, colors.black)
- draw_text_lr(mon, 2, 17, 0, "MaxFlow", format_int(gateExtra.getSignalLowFlow()) .. " rf/t", colors.lightGray, colors.lightGray, colors.black)
- drawButtons(18)
- sleep(0.1)
- end
- end
- parallel.waitForAny(buttons, update)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement