Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local upper = 0.90
- local lower = 0.10
- local redstoneSide = ''
- cellCount = 0
- connectedCells = {}
- monitorCount = 0
- connectedMonitors = {}
- TE5Cell = 0
- periList = table.pack(peripheral.find('thermalexpansion:storage_cell'))
- for i,v in ipairs(periList) do
- local periFunctions = {
- ['thermalexpansion:storage_cell'] = function()
- cellCount = cellCount + 1
- TE5Cell = TE5Cell + 1
- connectedCells[cellCount] = periList[i]
- end
- }
- end
- if cellCount == 0 then
- print('No RF Storage Found. Exiting Script!')
- return
- end
- if monitorCount == 0 then
- print('No Monitor Found. Exiting Script!')
- return
- end
- for i = 1, #connectedMonitors do
- local monitor = peripheral.wrap(connectedMonitors[i])
- end
- print('Peripherals Connected:')
- if monitorCount > 1 then print(monitorCount..' Monitors') else print(monitorCount..' Monitor') end
- if TE5Cell ~= 1 then print(TE5Cell..' TE Energy Cells') else print(TE5Cell..' TE Energy Cell') end
- if reactor ~= nil then print('1 Reactor') else print('0 Reactors') end
- if redstoneSide ~= 'none' then redstone.setOutput(redstoneSide, false) end
- if reactor ~= nil then reactor.setActive(false) end
- for i = 1, #connectedMonitors do
- local monitor = peripheral.wrap(connectedMonitors[i])
- monitor.clear()
- monitor.setBackgroundColor((colors.gray))
- monitor.setCursorPos(1,4)
- monitor.write(' ON ')
- monitor.setBackgroundColor((colors.green))
- monitor.setCursorPos(5,4)
- monitor.write(' OFF ')
- monitor.setBackgroundColor((colors.black))
- end
- while true do
- local eNow = 0 eMax = 0 cellLoops = 0
- for i = 1, cellLoops == #connectedCells do
- cell = peripheral.wrap(connectedCells[i])
- eNow = eNow + cell.getEnergyStored()
- eMax = eMax + cell.getMaxEnergyStored()
- cellLoops = i
- end
- local fill = eNow / eMax
- if eNow >= 1000000000 then eNowScale = 'billion'
- elseif eNow >= 1000000 then eNowScale = 'million'
- else eNowScale = 'none' end
- if eMax >= 1000000000 then eMaxScale = 'billion'
- elseif eMax >= 1000000 then eMaxScale = 'million'
- else eMaxScale = 'none' end
- if eNowScale == 'billion' then eNowValue = math.ceil(eNow / 1000000)
- elseif eNowScale == 'million' then eNowValue = math.ceil(eNow / 1000)
- else eNowValue = math.ceil(eNow) end
- if eMaxScale == 'billion' then eMaxValue = math.ceil(eMax / 1000000)
- elseif eMaxScale == 'million' then eMaxValue = math.ceil(emax / 1000)
- else eMaxScale = math.ceil(eMax) end
- if eNowScale == 'billion' then eNowSuffix = 'mRF'
- elseif eNowScale == 'million' then eNowSuffix = 'kRF'
- else eNowSuffix = 'RF' end
- if eMaxScale == 'billion' then eMaxSuffix = 'mRF'
- elseif eMaxScale == 'million' then eMaxSuffix = 'kRF'
- else eMaxSuffix = 'RF' end
- local eNowDigitCount = 0 eMaxDigitCount = 0
- for digit in string.gmatch(eNowValue, '%d') do eNowDigitCount = eNowDigitCount + 1 end
- for digit in string.gmatch(eMaxValue, '%d') do eMaxDigitCount = eMaxDigitCount + 1 end
- eNowX = 16 - eNowDigitCount
- eMaxX = 16 - eMaxDigitCount
- for i = 1, #connectedMonitors do
- local monitor=peripheral.wrap(connectedMonitors[i])
- monitor.setCursorPos(10,3)
- monitor.write(' ')
- monitor.setCursorPos(10,5)
- monitor.write(' ')
- monitor.setCursorPos(2,2)
- monitor.write('Engines:')
- monitor.setCursorPos(11,2)
- monitor.write('Storage:')
- monitor.setCursorPos(eNowX, 3)
- monitor.write(eNowValue..eNowSuffix)
- monitor.setCursorPos(eMaxX, 4)
- monitor.write('of:')
- monitor.setCursorPos(eMaxX, 5)
- monitor.write(eMaxValue..eMaxSuffix)
- if fill > upper then
- if redstoneSide ~= 'none' then redstone.setOutput(redstoneSide, false) end
- if reactor ~= nil then reactor.setActive(false) end
- monitor.setBackgroundColor((colors.gray))
- monitor.setCursorPos(1,4)
- monitor.write(' ON ')
- monitor.setBackgroundColor((colors.green))
- monitor.setCursorPos(5,4)
- monitor.write(' OFF ')
- monitor.setBackgroundColor((colors.black))
- elseif fill < lower then
- if redstoneSide ~= 'none' then redstone.setOutput(redstoneSide, true) end
- if reactor ~= nil then reactor.setActive(true) end
- monitor.setBackgroundColor((colors.gray))
- monitor.setCursorPos(1,4)
- monitor.write(' ON ')
- monitor.setBackgroundColor((colors.green))
- monitor.setCursorPos(5,4)
- monitor.write(' OFF ')
- monitor.setBackgroundColor((colors.black))
- end
- end
- sleep(1)
- end
Add Comment
Please, Sign In to add comment