Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Setup
- --local modem = peripheral.wrap("left")
- local capacitorSide = "top"
- local cellType = 1 --basic,normal,vibrant
- local cells = 8
- local rsOutSide = "bottom"
- local boiler = {colors.orange,colors.red,colors.blue}
- local rsOut = 0
- local newRsOut = 0
- local boilerOn = {false,false,false}
- --local txChannel = 1400
- --local rxChannel = 1410
- local mon = peripheral.wrap("back")
- for i = 1,3 do
- rsOut = colors.combine(rsOut, boiler[i] )
- newRsOut = rsOut
- end
- redstone.setBundledOutput(rsOutSide, rsOut)
- --Variables
- local cellsCapacities = {1000000,5000000,25000000}
- local cellCapacity = (cellsCapacities[cellType]) * (cells)
- local capacitor_1 = peripheral.wrap(capacitorSide)
- local energyLevelOld = 0
- mon.setTextScale(0.5)
- x, y = mon.getSize()
- --Functions
- function drawCentered(line, text)
- mon.setCursorPos((x - string.len(text))/ 2, line)
- mon.write(text)
- end
- function drawAcross(line, char)
- mon.setCursorPos(1, line)
- for i = 1, x do
- mon.write(char)
- end
- end
- function drawPcBar(line, char, size)
- oldColor = mon.getTextColor()
- mon.setCursorPos(1, line)
- mon.clearLine()
- maxLengt = math.ceil(x * 0.8)
- sizeB = math.ceil(size*maxLengt/100)
- mon.setTextColor( colors.white )
- mon.setCursorPos(1, line)
- mon.write("[")
- mon.setCursorPos(2, line)
- if size < 25 then newColor = colors.red end
- if ((size < 75) and (size > 25)) then newColor = colors.orange end
- if size > 75 then newColor = colors.lime end
- mon.setTextColor( newColor )
- for i = 1, sizeB do
- mon.write(char)
- end
- mon.setCursorPos((maxLengt+2), line)
- mon.setTextColor( colors.white )
- mon.write("] "..size.."%")
- mon.setTextColor( oldColor )
- end
- function showRatio(line, num1, num2)
- oldColor = mon.getTextColor()
- mon.setCursorPos(1, line)
- mon.clearLine()
- mon.setTextColor( colors.white )
- mon.write(num1.."/"..num2)
- end
- function resetNewRsOut ()
- for i = 1,3 do
- newRsOut = colors.combine(newRsOut, boiler[i] )
- end
- end
- --body
- --prepare screen
- mon.clear()
- mon.setTextColor( colors.white )
- mon.setBackgroundColor(colors.gray)
- drawCentered(2, "Power storage monitoring")
- drawAcross(3, "=")
- --Steam production
- drawAcross(6, "-")
- mon.setTextColor(colors.yellow)
- mon.setCursorPos(5,7)
- mon.write("Steam production:")
- --Power storage
- mon.setTextColor( colors.white )
- drawAcross(20, "-")
- mon.setTextColor(colors.yellow)
- mon.setCursorPos(5,21)
- mon.write("RF storage:")
- while true do
- --Get the capacitor datas
- energyLevel = capacitor_1.getEnergyStored()
- energyLevel = (energyLevel) * (cells)
- local pcCap = (energyLevel*100)/cellCapacity --RF stored in %
- pcCap = math.ceil(pcCap)
- drawPcBar(22, "#", pcCap)
- showRatio(23, energyLevel, cellCapacity)
- if pcCap < 90 then
- boilerOn[1] = true
- else
- boilerOn[1] = false
- end
- if pcCap < 75 then
- boilerOn[2] = true
- else
- boilerOn[2] = false
- end
- if pcCap < 50 then
- boilerOn[3] = true
- else
- boilerOn[3] = false
- end
- for i = 1,3 do
- if boilerOn[i] == true then
- newRsOut = colors.subtract(colors.combine(newRsOut), boiler[i])
- end
- end
- if newRsOut == rsOut then
- resetNewRsOut ()
- else
- rsOut = newRsOut
- redstone.setBundledOutput(rsOutSide, rsOut)
- end
- sleep(math.random(0,10))
- end
Add Comment
Please, Sign In to add comment