Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Simple Energy storage display for redstone energy cells
- and on-demand engine control
- The engine control part is optional, don't connect a rednet
- cable if you only want to display energy storage.
- by got_m1lk
- --]]
- --Specify side of wired modem
- -- Valid: "left", "right", "front", "back", "top", "bottom"
- local modemside = "bottom"
- --Specify side of rednet cable
- local rednetside = "back"
- --Specify side of monitor
- --If the monitor is attached to the modem specify peripheral-ID instead.
- local monitorside = "top"
- --Adjust the textscale if you have a bigger/smaller monitor
- --Increments of 0.5
- local textsize = 1
- --Specify at what percentage the engines turn on
- local min = 25
- --Specify at what percentage the engines turn off
- local max = 95
- --Specify the peripheral-IDs of you redstone cells
- --Remove/add units from the table to fit it to the amount
- -- of cells you are using
- local storageUnits = {
- {
- ["id"] = "cofh_thermalexpansion_energycell_3",
- ["name"] = "Cell1"
- },
- {
- ["id"] = "cofh_thermalexpansion_energycell_4",
- ["name"] = "Cell2"
- }--[[,
- {
- ["id"] = "redstone_energy_cell_2",
- ["name"] = "Cell3"
- },
- {
- ["id"] = "redstone_energy_cell_3",
- ["name"] = "Cell4"
- } --]]
- }
- local mon = peripheral.wrap(monitorside)
- local net = peripheral.wrap(modemside)
- mon.clear()
- mon.setTextScale(textsize)
- mon.setTextColor(512)
- mon.setCursorPos(1,2)
- mon.write(" Energy Remaining:")
- mon.setCursorPos(1,10)
- mon.write(" Engine Status:")
- mon.setTextColor(2)
- rs.setBundledOutput(rednetside,colors.black)
- while true do
- capacity = 0
- amount = 0
- for i=#storageUnits,1,-1 do
- storageUnit = storageUnits[i]
- capacity = capacity + net.callRemote(storageUnit["id"], "getMaxEnergyStored", "unknown")
- amount = amount + net.callRemote(storageUnit["id"], "getEnergyStored", "unknown")
- end
- percentage = tonumber((amount / capacity) *100)
- percentage = math.floor(percentage)
- if percentage <= min then
- rs.setBundledOutput(rednetside,colors.white)
- end
- if percentage >= max then
- rs.setBundledOutput(rednetside,colors.black)
- end
- percentage = string.match(tostring(percentage),'[^%.]+')
- mon.setCursorPos(8,4)
- mon.clearLine()
- mon.setTextColor(2)
- mon.write(percentage .. "%")
- mon.setCursorPos(1,6)
- mon.clearLine()
- mon.setTextColor(512)
- mon.write("Energy: ")
- mon.setTextColor(2)
- mon.write(string.match(tostring(amount),'[^%.]+') .. " MJ")
- mon.setCursorPos(1,7)
- mon.clearLine()
- mon.setTextColor(512)
- mon.write(" Size: ")
- mon.setTextColor(2)
- mon.write(string.match(tostring(capacity),'[^%.]+') .." MJ")
- if rs.getBundledInput(rednetside) == colors.black then
- mon.setTextColor(colors.red)
- mon.setCursorPos(8,11)
- mon.write("OFF")
- elseif rs.getBundledInput(rednetside) == colors.white then
- mon.setTextColor(colors.lime)
- mon.setCursorPos(8,11)
- mon.write(" ON")
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement