Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("monitor_2")
- r = peripheral.wrap("back")
- c1 = peripheral.wrap("tile_thermalexpansion_cell_hardened_name_2")
- c2 = peripheral.wrap("tile_thermalexpansion_cell_hardened_name_3")
- c3 = peripheral.wrap("tile_thermalexpansion_cell_hardened_name_4")
- --capacitors = 4
- buttonState = r.getActive()
- buttonLabel = ""
- if buttonState then
- buttonLabel = "Active"
- else
- buttonLabel = "Inactive"
- end
- powerValues = {}
- function cells()
- return c1.getEnergyStored() + c2.getEnergyStored() + c3.getEnergyStored()
- end
- function cellsMax()
- return c1.getMaxEnergyStored() + c2.getMaxEnergyStored() + c3.getMaxEnergyStored()
- end
- function addCommas(int)
- str = tostring(int)
- newStr = ""
- counter = 1
- for i = string.len(str), 1, -1 do
- if counter %3 == 0 then
- newStr = "," ..string.sub(str, i, i) ..newStr
- else
- newStr = string.sub(str, i, i) ..newStr
- end
- counter = counter + 1
- end
- return newStr
- end
- function updateScreen()
- m.clear()
- m.setCursorPos(1, 1)
- for k, v in pairs(powerValues) do
- m.write(v["Name"] ..": " ..v["Value"])
- x, y = m.getCursorPos()
- m.setCursorPos(1, y + 1)
- end
- end
- function updateValues()
- tempValues = {}
- tempValues[1] = {}
- tempValues[1]["Name"] = "Energy"
- tempValues[1]["Value"] = addCommas(cells()) .." / " ..addCommas(cellsMax())
- tempValues[2] = {}
- tempValues[2]["Name"] = "Reactor Buffer"
- tempValues[2]["Value"] = addCommas(r.getEnergyStored())
- tempValues[3] = {}
- tempValues[3]["Name"] = "Fuel"
- tempValues[3]["Value"] = r.getFuelAmount()
- tempValues[4] = {}
- tempValues[4]["Name"] = "Waste"
- tempValues[4]["Value"] = r.getWasteAmount()
- tempValues[5] = {}
- tempValues[5]["Name"] = "RF/T"
- tempValues[5]["Value"] = r.getEnergyProducedLastTick()
- if powerValues ~= tempValues then
- powerValues = tempValues
- updateScreen()
- end
- end
- x, y = m.getSize()
- if buttonState then
- m.setBackgroundColor(colors.lime)
- else
- m.setBackgroundColor(colors.red)
- end
- for i = 1, x, 1 do
- m.setCursorPos(i, y - 2)
- m.write(" ")
- end
- start = (x / 2) - (string.len(buttonLabel) / 2)
- End = start + string.len(buttonLabel)
- counter = 1
- for i = 1, x, 1 do
- m.setCursorPos(i, y - 1)
- if i < start and i > End then
- m.write(" ")
- else
- m.write(string.sub(buttonLabel, counter, counter))
- counter = counter + 1
- end
- end
- m.setBackgroundColor(colors.black)
- while true do
- updateValues()
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment