Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --modem
- mod = peripheral.wrap("right")
- --1.Cell
- cell1 = peripheral.wrap("cofh_thermalexpansion_energycell_1")
- --2.Cell
- cell2 = peripheral.wrap("cofh_thermalexpansion_energycell_2")
- --3.Cell
- cell3 = peripheral.wrap("cofh_thermalexpansion_energycell_3")
- --4.Cell
- cell4 = peripheral.wrap("cofh_thermalexpansion_energycell_4")
- --Monitor
- mon = peripheral.wrap("left")
- function calculate()
- --1.Cell
- cell1Stored = cell1.getEnergyStored("right")
- cell1Full = cell1.getMaxEnergyStored("right")
- cell1Precent = math.floor(100*cell1Stored/cell1Full)
- cell1Bar = math.floor(cell1Precent/5)
- --2.Cell
- cell2Stored = cell2.getEnergyStored("right")
- cell2Full = cell2.getMaxEnergyStored("right")
- cell2Precent = math.floor(100*cell2Stored/cell2Full)
- cell2Bar = math.floor(cell2Precent/5)
- --3.Cell
- cell3Stored = cell3.getEnergyStored("right")
- cell3Full = cell3.getMaxEnergyStored("right")
- cell3Precent = math.floor(100*cell3Stored/cell3Full)
- cell3Bar = math.floor(cell3Precent/5)
- --4.Cell
- cell4Stored = cell4.getEnergyStored("right")
- cell4Full = cell4.getMaxEnergyStored("right")
- cell4Precent = math.floor(100*cell4Stored/cell4Full)
- cell4Bar = math.floor(cell4Precent/5)
- end
- function reset()
- mon.clear()
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,1)
- end
- function draw()
- --1.Cell
- if cell1Precent < 30 then
- mon.setTextColor(colors.red)
- elseif (cell1Precent > 30) and (cell1Precent < 60) then
- mon.setTextColor(colors.yellow)
- else
- mon.setTextColor(colors.lime)
- end
- mon.write("1.Stored:"..tonumber(cell1Stored).."RF")
- mon.setCursorPos(1,2)
- mon.write("1.Max:"..tonumber(cell1Full).."RF")
- mon.setCursorPos(1,3)
- mon.write("1.Precent:"..tonumber(cell1Precent).."% ")
- mon.setCursorPos(16,3)
- mon.setBackgroundColor(colors.blue)
- for i = 1, 20 do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.orange)
- mon.setCursorPos(16,3)
- for i = 1, cell1Bar do
- mon.write(" ")
- end
- --2.Cell
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(1,5)
- if cell2Precent < 30 then
- mon.setTextColor(colors.red)
- elseif (cell2Precent > 30) and (cell2Precent < 60) then
- mon.setTextColor(colors.yellow)
- else
- mon.setTextColor(colors.lime)
- end
- mon.write("2.Stored:"..tonumber(cell2Stored).."RF")
- mon.setCursorPos(1,6)
- mon.write("2.Max:"..tonumber(cell2Full).."RF")
- mon.setCursorPos(1,7)
- mon.write("2.Precent:"..tonumber(cell2Precent).."% ")
- mon.setCursorPos(16,7)
- mon.setBackgroundColor(colors.blue)
- for i = 1, 20 do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.orange)
- mon.setCursorPos(16,7)
- for i = 1, cell2Bar do
- mon.write(" ")
- end
- --3.Cell
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(1,9)
- if cell3Precent < 30 then
- mon.setTextColor(colors.red)
- elseif (cell3Precent > 30) and (cell3Precent < 60) then
- mon.setTextColor(colors.yellow)
- else
- mon.setTextColor(colors.lime)
- end
- mon.write("3.Stored:"..tonumber(cell3Stored).."RF")
- mon.setCursorPos(1,10)
- mon.write("3.Max:"..tonumber(cell3Full).."RF")
- mon.setCursorPos(1,11)
- mon.write("3.Precent:"..tonumber(cell3Precent).."%")
- mon.setCursorPos(16,11)
- mon.setBackgroundColor(colors.blue)
- for i = 1, 20 do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.orange)
- mon.setCursorPos(16,11)
- for i = 1, cell3Bar do
- mon.write(" ")
- end
- --4.Cell
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(1,13)
- if cell4Precent < 30 then
- mon.setTextColor(colors.red)
- elseif (cell4Precent > 30) and (cell4Precent < 60) then
- mon.setTextColor(colors.yellow)
- else
- mon.setTextColor(colors.lime)
- end
- mon.write("4.Stored:"..tonumber(cell4Stored).."RF")
- mon.setCursorPos(1,14)
- mon.write("4.Max:"..tonumber(cell4Full).."RF")
- mon.setCursorPos(1,15)
- mon.write("4.Precent:"..tonumber(cell4Precent).."%")
- mon.setCursorPos(16,15)
- mon.setBackgroundColor(colors.blue)
- for i = 1, 20 do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.orange)
- mon.setCursorPos(16,15)
- for i = 1, cell4Bar do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.black)
- sleep(1)
- end
- calculate()
- reset()
- draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement