Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local core = peripheral.wrap("draconic_rf_storage_7")
- local gate = peripheral.wrap("flux_gate_47")
- local monitor = peripheral.wrap("monitor_124")
- 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 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
- function buttons()
- while true do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- if yPos == 11 then
- local cFlow = gate.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 >= 17 and xPos <= 19 then cFlow = cFlow+1000000
- elseif xPos >= 21 and xPos <= 23 then cFlow = cFlow+100000
- elseif xPos >= 25 and xPos <= 27 then cFlow = cFlow+10000
- end
- gate.setSignalLowFlow(cFlow)
- 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, 17, y, ">>>", colors.white, colors.gray)
- draw_text(mon, 21, y, ">> ", colors.white, colors.gray)
- draw_text(mon, 25, y, "> ", colors.white, colors.gray)
- end
- local eMax
- local eNow
- local ePercent
- local eLast = 0
- local eFlow
- function update()
- while true do
- clear(mon)
- -- energy core infos
- 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()
- print()
- print("FluxGate flow: " .. gate.getSignalLowFlow())
- -- monitor display
- draw_text(mon, 2, 2, "ENERGY CORE", colors.red, colors.black)
- draw_text_right(mon, 1, 2, "Tier 7", colors.purple, colors.black)
- draw_text(mon, 2, 4, "Current capacity:", colors.blue, colors.black)
- draw_text_right(mon, 1, 4, ePercent .. " %", colors.white, colors.black)
- draw_text_right(mon, 1, 5, format_int(eNow) .. " rf", colors.lightGray, colors.black)
- draw_text(mon, 2, 9, "Energie do sveta", colors.orange, colors.black)
- draw_text(mon, 2, 10, " Flow:", colors.yellow, colors.black)
- draw_text_right(mon, 1, 10, format_int(gate.getSignalLowFlow()) .. " rf/t", colors.white, colors.black)
- drawButtons(11)
- sleep(0.1)
- end
- end
- parallel.waitForAny(buttons, update)
Advertisement
Add Comment
Please, Sign In to add comment