Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor_side = "left"
- local modem_side = "back"
- local cell_ids = {
- "redstone_energy_cell_0",
- "redstone_energy_cell_1",
- "redstone_energy_cell_2",
- "redstone_energy_cell_3"
- }
- local net = peripheral.wrap(modem_side)
- local mon = peripheral.wrap(monitor_side)
- local cell = {}
- for k,v in pairs(cell_ids) do
- cell[k] = peripheral.wrap(v)
- end
- mon.clear()
- --Adjust the textscale if you have a bigger/smaller monitor
- --Increments of 0.5
- mon.setTextScale(1)
- mon.setTextColor(512)
- mon.setCursorPos(1,1)
- mon.write("Energy status:")
- while true do
- local line = 1
- local totalEnergy = 0
- local totalMaxEnergy = 0
- for k,v in pairs(cell) do
- line=line+1
- totalEnergy = totalEnergy + cell[k].getEnergyStored()
- totalMaxEnergy = totalMaxEnergy + cell[k].getMaxEnergyStored()
- energy = math.floor(cell[k].getEnergyStored() / 100) / 10
- percent = cell[k].getEnergyStored() / cell[k].getMaxEnergyStored()
- maxEnergy = math.floor(cell[k].getMaxEnergyStored() / 100) / 10
- percent = math.floor(percent * 1000) / 10
- energy = string.format("%3.1f", energy)
- maxEnergy = string.format("%3.1f", maxEnergy)
- percent = string.format("%3.1f", percent)
- mon.setCursorPos(1,line)
- mon.write(tostring(k) .. ":")
- mon.setCursorPos(4,line)
- mon.write(energy.."k")
- mon.setCursorPos(13,line)
- mon.write(percent.."%")
- end
- line=line+1
- energy = math.floor(totalEnergy / 100000) / 10
- percent = math.floor(totalEnergy / totalMaxEnergy * 1000) / 10
- energy = string.format("%3.1f", energy)
- percent = string.format("%3.1f", percent)
- mon.setCursorPos(4,line)
- mon.write(energy.."M")
- mon.setCursorPos(13,line)
- mon.write(percent.."%")
- os.sleep(3)
- end
Advertisement
Add Comment
Please, Sign In to add comment