Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require('paint_utils_fix')
- fixPaintUtils()
- local version = '3.1'
- local W, H = term.getSize()
- local mon = peripheral.find('monitor')
- local monW, monH = mon.getSize()
- function draw(f)
- term.f()
- mon.f()
- end
- sides = {'top', 'bottom', 'left', 'right', 'front', 'back'}
- local chamber = peripheral.find('ic2:reactor_chamber')
- local core = chamber.getReactorCore()
- local heat_cutoff = 84
- local ticker = 1
- local nuke_img = paintutils.loadImage('reactor/nuke.nfp')
- local timeout = os.startTimer(1)
- local requirement = {}
- requirement['temperature'] = {
- active = true,
- reverse = false,
- name = 'temperature',
- check = function() return reactor.heat/reactor.maxHeat*100 < heat_cutoff end
- }
- for n = 1, #sides, 1 do
- requirement[sides[n]] = {
- active = false,
- reverse = false,
- name = sides[n],
- check = function() return redstone.getInput(sides[n]) end
- }
- end
- while true do
- local event = {os.pullEvent()}
- if event[1] == 'mouse_click' or event[1] == 'monitor_touch' then
- if event[3] == math.floor(W/2-5) then
- local y = 5
- for req, content in pairs(requirement) do
- if event[4] == y then
- content.active = not content.active
- end
- y = y + 1
- end
- end
- if event[3] == math.floor(W/2-3) then
- local y = 5
- for req, content in pairs(requirement) do
- if event[4] == y then
- content.reverse = not content.reverse
- end
- y = y + 1
- end
- end
- if event[4] >= 13 and event[4] <= 14 then
- if event[3] >=2 and event[3] <= W/2 then
- heat_cutoff = (event[3]-1)/(W/2-1)*100
- end
- end
- elseif event[1] == 'mouse_scroll' then
- if event[4] >= 13 and event[4] <= 14 then
- if event[3] >=2 and event[3] <= W/2 then
- heat_cutoff = math.floor((heat_cutoff - 0.5*event[2])*2)/2
- end
- end
- elseif event[1] == 'timer' then
- ticker = ticker + 1
- if ticker > 4 then
- ticker = 0
- end
- timeout = os.startTimer(1)
- end
- reactor = core.getMetadata().reactor
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.white)
- for x = 1, W, 1 do
- term.setCursorPos(x, 1)
- term.write(' ')
- end
- term.setCursorPos(1, 1)
- term.write('Reactor Manager v'..version)
- for n = 1, ticker, 1 do
- term.setCursorPos(W-11+n, 1)
- term.write('|')
- end
- term.setBackgroundColor(colors.black)
- -- Tip
- term.setCursorPos(1, H-1)
- term.write('R - required')
- term.setCursorPos(1, H)
- term.write('F - fulfilled')
- term.setTextColor(colors.white)
- term.setCursorPos(W/2-5, 3)
- term.write('R')
- term.setTextColor(colors.white)
- term.setCursorPos(W/2-3, 3)
- term.write('\172')
- term.setCursorPos(W/2, 3)
- term.setTextColor(colors.lightGray)
- term.write('F')
- local y = 5
- for req, content in pairs(requirement) do
- if y%2 == 0 then
- term.setBackgroundColor(colors.black)
- else
- term.setBackgroundColor(colors.gray)
- end
- term.setCursorPos(2, y)
- for n = 1, W/2, 1 do
- term.write(' ')
- end
- term.setTextColor(colors.white)
- term.setCursorPos(2, y)
- term.write(req)
- term.setCursorPos(W/2-5, y)
- if content.active then
- term.write('\7')
- end
- term.setCursorPos(W/2-3, y)
- if content.reverse then
- term.write('\238')
- end
- term.setCursorPos(W/2, y)
- term.setTextColor(colors.lightGray)
- if content.check() and not content.reverse or not content.check() and content.reverse then
- term.write('\7')
- end
- y = y + 1
- end
- --[[local y = 3
- for n = 1, 54, 1 do
- if core.getItemMeta(n) ~= nil and core.getItemMeta(n).name:find('fuel') then
- term.setCursorPos(W/2, y)
- term.write(math.floor(core.getItemMeta(n).durability*100)..'%')
- y = y + 1
- end
- end]]
- for n = 1, W/2, 1 do
- if n/(W/2)*100 <= heat_cutoff then
- if math.floor(n/(W/2)*100) >= 85 then
- term.setBackgroundColor(colors.red)
- elseif math.floor(n/(W/2)*100) >= 70 then
- term.setBackgroundColor(colors.orange)
- elseif math.floor(n/(W/2)*100) >= 50 then
- term.setBackgroundColor(colors.yellow)
- elseif math.floor(n/(W/2)*100) >= 40 then
- term.setBackgroundColor(colors.white)
- else
- term.setBackgroundColor(colors.blue)
- end
- term.setCursorPos(1+n, 13)
- term.write(' ')
- term.setCursorPos(1+n, 14)
- term.write(' ')
- else
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.gray)
- term.setCursorPos(1+n, 13)
- term.write('\127')
- term.setCursorPos(1+n, 14)
- term.write('\127')
- end
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(W/2+2-string.len(heat_cutoff..'%'), 15)
- term.write(heat_cutoff..'%')
- paintutils.drawImage(nuke_img, W/2+5, 3)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(W/2+5, H-1)
- term.write(math.floor(reactor.euOutput)..' EU/t')
- term.setCursorPos(W/2+6+string.len(math.floor(reactor.euOutput)..' EU/t'), H-1)
- if math.floor(reactor.heat/reactor.maxHeat*100) >= 85 then
- term.setTextColor(colors.red)
- elseif math.floor(reactor.heat/reactor.maxHeat*100) >= 70 then
- term.setTextColor(colors.orange)
- elseif math.floor(reactor.heat/reactor.maxHeat*100) >= 50 then
- term.setTextColor(colors.yellow)
- elseif math.floor(reactor.heat/reactor.maxHeat*100) >= 40 then
- term.setTextColor(colors.white)
- else
- term.setTextColor(colors.blue)
- end
- term.write(math.floor(reactor.heat/reactor.maxHeat*100)..'% heat')
- -- Core logic
- local reactor_on = true
- for req, content in pairs(requirement) do
- if ((not content.check() and not content.reverse) or (content.check() and content.reverse)) and content.active then
- reactor_on = false
- end
- end
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.white)
- term.setCursorPos(W-4, 1)
- term.write(tostring(reactor_on))
- redstone.setOutput('top', reactor_on)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement