Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- allNames = peripheral.getNames()
- monitor = peripheral.wrap("top")
- monitor.setCursorPos(1, 1)
- monitor.clear()
- monX, monY = monitor.getSize()
- monitor.setTextScale(0.5)
- monitor.setTextColor(43)
- monitor.setCursorBlink(true)
- monitor.write("Starting...")
- monitor.setCursorPos(1, 2)
- function write(msg)
- curX, curY = monitor.getCursorPos()
- monitor.write(msg)
- if curY == monY then
- monitor.scroll(1)
- monitor.setCursorPos(1, monY)
- else
- monitor.setCursorPos(1, curY + 1)
- end
- end
- function getReactorName()
- for x = 1, #allNames do
- if string.match(allNames[x], "_Reactor_") then
- return allNames[x]
- end
- end
- end
- function getCellName()
- for x = 1, #allNames do
- if string.match(allNames[x], "ender_cell") then
- return allNames[x]
- end
- end
- end
- reactorName = getReactorName()
- enderCell = getCellName()
- if reactorName == nil and enderCell == nil then
- write("Can't find 'Bigger Reactors' reactor or 'Powah' Ender Cell")
- exit()
- else
- write("Found reactor and Cell")
- end
- reactor = peripheral.wrap(reactorName)
- cell = peripheral.wrap(enderCell)
- prevCellLevel = cell.getEnergy() / cell.getEnergyCapacity()
- function monitorPower()
- while true do
- currentRodPercent = reactor.getControlRod(0).level()
- cellLevel = cell.getEnergy() / cell.getEnergyCapacity()
- cellLevelRounded = cellLevel * 100
- cellLevelRounded = math.floor(cellLevelRounded)
- write("Battery level: " .. cellLevelRounded .. "%")
- if cellLevelRounded ~= 100 then
- if cellLevel > prevCellLevel then
- if currentRodPercent == 99.9 then
- write("Can't push anymore")
- else
- reactor.setAllControlRodLevels(currentRodPercent + .1)
- write("Pushing rods, " .. currentRodPercent + .1 .. "%")
- end
- else
- reactor.setAllControlRodLevels(currentRodPercent - 1)
- write("Pulling rods, " .. currentRodPercent - 1 .. "%")
- end
- else
- reactor.setAllControlRodLevels(99.9)
- write("Setting rods to 99.9%")
- end
- prevCellLevel = cellLevel
- sleep(30)
- end
- end
- monitorPower()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement