Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- reactors = {peripheral.find("BigReactors-Reactor")}
- reactor = reactors[1]
- reactors = nil
- --reactor.setActive(false)
- minBuffer = 1000000
- --maxBuffer = 9000000
- reactorActive = reactor.getActive()
- monitor1 = peripheral.wrap("top")
- line = 1
- w,h = monitor1.getSize()
- bufferFullness = 0
- numberOfCells = 0
- energyCells = {peripheral.find("tile_thermalexpansion_cell_resonant_name")}
- for _ in pairs(energyCells) do numberOfCells = numberOfCells + 1 end
- maxEnergy = 10000000 + numberOfCells * 80000000 --80m per cell and 10m for the reactor
- maxBuffer = maxEnergy - 1000000
- --run this each loop before getBackground
- function getTotalEnergy()
- local en = 0
- en = en + reactor.getEnergyStored()
- for i = 1, numberOfCells, 1 do
- en = en + energyCells[i].getEnergyStored()
- end
- return en
- end
- totalEnergy = getTotalEnergy()
- --returns background when given x position
- function getCharacterBackground(pos)
- if pos > w * totalEnergy / maxEnergy then
- return "4"
- else
- return "5"
- end
- end
- --calculates the background for word at a specific position, returns a string
- function getBackground(first, last)
- local bg = ""
- local i = first
- repeat
- bg = bg .. getCharacterBackground(i)
- i = i + 1
- until i > last
- return bg
- end
- function fillSpace(first, last)
- local spaces = ""
- local charClr = ""
- local i = first
- repeat
- spaces = spaces .. " "
- charClr = charClr .. "0"
- i = i + 1
- until i > last
- monitor1.blit(spaces, charClr, getBackground(first, last))
- end
- function finishLine()
- local x,y = monitor1.getCursorPos()
- fillSpace(x, w)
- end
- function textWithBackground(lnStr)
- local x,y = monitor1.getCursorPos()
- local charClr = ""
- for i = 1, string.len(lnStr), 1 do
- charClr = charClr .. "f"
- end
- bg = getBackground(x, x + string.len(lnStr) - 1)
- monitor1.blit(lnStr, charClr, bg)
- end
- function fullLine(lnStr)
- textWithBackground(lnStr)
- finishLine()
- end
- lineStr = ""
- print("Starting up...")
- while true do
- line = 0
- monitor1.clear()
- totalEnergy = getTotalEnergy()
- print(totalEnergy)
- monitor1.setCursorPos(1, 1 + line)
- monitor1.write("Reactor Status: ")
- if (reactorActive) then
- monitor1.blit("ACTIVE", "dddddd", "ffffff")
- else
- monitor1.blit("INACTIVE", "eeeeeeee", "ffffffff")
- end
- line = line + 1
- monitor1.setCursorPos(1, 1 + line)
- monitor1.write("Energy: " .. totalEnergy .. "/" .. maxEnergy .. " RF")
- line = line + 1
- monitor1.setCursorPos(1, 1 + line)
- textWithBackground("Test!")
- finishLine()
- line = line + 1
- monitor1.setCursorPos(1, 1 + line)
- fullLine("IT IS ALIVE!")
- --monitor1.setCursorPos(1, 1 + line)
- --bufferFullness = 10 * totalEnergy / maxEnergy
- --for i = 1, bufferFullness, 1 do
- -- monitor1.blit(" ","5","5")
- --end
- --for i = 1, 10 - bufferFullness, 1 do
- -- monitor1.blit(" ","4","4")
- --end
- --line = line + 1
- if (reactorActive) then
- if (totalEnergy > maxBuffer) then
- reactor.setActive(false)
- reactorActive = false
- print("Buffer full, shutting down")
- monitor1.setCursorPos(w / 2 - 6, h / 2)
- monitor1.blit("Shutting Down...", "dddddddddddddddd", "0000000000000000")
- os.sleep(10)
- end
- else
- if (totalEnergy < minBuffer) then
- reactor.setActive(true)
- reactorActive = true
- print("Buffer empty, restarting reactor")
- monitor1.setCursorPos(w / 2 - 6, h / 2)
- monitor1.blit("Starting Up...", "dddddddddddddd", "00000000000000")
- os.sleep(10)
- end
- end
- os.sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement