Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local upper = 0.90
- local lower = 0.10
- isError=0
- function detectDevice(DeviceName)
- DeviceSide="none"
- for k,v in pairs(redstone.getSides()) do
- if peripheral.getType(v)==DeviceName then
- DeviceSide = v
- break
- end
- end
- return(DeviceSide)
- end
- cell="none"
- monitor="none"
- local peripheralList = peripheral.getNames()
- CellSide=detectDevice("cofh_thermalexpansion_energycell")
- if CellSide=="none" then
- cell=peripheral.wrap(CellSide)
- print ("TE Energy Cell on the " .. CellSide .. " connected.")
- else
- CellSide=detectDevice("title_enderio_blockcapacitor_name")
- if CellSide=="none" then
- cell=peripheral.wrap(CellSide)
- print ("EnderIO Capacitor Bank on the " .. CellSide .. " connected.")
- else
- for Index = 1, #peripheralList do
- if string.find(peripheralList[Index], "cofh_thermalexpansion_energycell") then
- cell=peripheral.wrap(peripheralList[Index])
- print ("TE Energy Cell on wired modem: " ..peripheralList[Index].." connected.")
- elseif string.find(peripheralList[Index], "tile_enderio_blockcapacitorbank_name") then
- cell=peripheral.wrap(peripheral[Index])
- print ("EnderIO Capacitor Bank on wired modem: "..peripheralList[Index].." connected.")
- end
- end
- if cell == "none" then
- print("No Energy storage found. Halting Program!")
- return
- end
- end
- end
- MonitorSide=detectDevice("monitor")
- if MonitorSide~="none" then
- monitor=peripheral.wrap(MonitorSide)
- print ("Monitor found on the " .. MonitorSide .. " connected.")
- else
- for Index = 1, #peripheralList do
- if string.find(peripheralList[Index], "monitor") then
- monitor=peripheral.wrap(peripheralList[Index])
- print ("Monitor found on the wired modem: "..peripheralList[Index].." connected.")
- end
- end
- if monitor == "none" then
- print ("Warning! - Monitor not found! Program is continuing!")
- end
- end
- redstone.setOutput("back", false)
- if monitor ~= "none" then
- monitor.clear()
- monitor.setBackgroundColour((colours.grey))
- monitor.setCursorPos(1,4)
- monitor.write(" ON ")
- monitor.setBackgroundColour((colours.green))
- monitor.setCursorPos(5,4)
- monitor.write(" OFF ")
- monitor.setBackgroundColour((colours.black))
- end
- while true do
- eNow = cell.getEnergyStored("unknown")
- eMax = cell.getMaxEnergyStored("unknown")
- fill = (eNow / eMax)
- if monitor ~= "none" then
- if eMax >= 10000000 then
- monitor.setCursorPos(11,2)
- monitor.write("Storage:")
- monitor.setCursorPos(11,3)
- monitor.write(math.ceil(eNow/1000).."kRF")
- monitor.setCursorPos(11,4)
- monitor.write("Of:")
- monitor.setCursorPos(11,5)
- monitor.write(math.ceil(eMax/1000).."kRF")
- else
- monitor.setCursorPos(11,2)
- monitor.write("Storage:")
- monitor.setCursorPos(11,3)
- monitor.write(math.ceil(eNow))
- monitor.setCursorPos(11,4)
- monitor.write("Of:")
- monitor.setCursorPos(11,5)
- monitor.write(math.ceil(eMax))
- end
- monitor.setSursorPos(1,2)
- monitor.write("Engines:")
- end
- if fill > upper then
- redstone.setOutput("back", false)
- if monitor ~= "none" then
- monitor.setBackgroundColour((colours.grey))
- monitor.setCursorPos(1,4)
- monitor.write(" ON ")
- monitor.setBackgroundColour((colours.green))
- monitor.setCursorPos(5,4)
- monitor.write(" OFF ")
- monitor.setBackgroundColour((colours.black))
- end
- elseif fill < lower then
- redstone.setOutput("back", true)
- if monitor ~= "none" then
- monitor.setBackgroundColour((colours.green))
- monitor.setCursorPos(1,4)
- monitor.write(" ON ")
- monitor.setBackgroundColour((colours.grey))
- monitor.setCursorPos(5,4)
- monitor.write(" OFF ")
- monitor.setBackgroundColour((colours.black))
- end
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement