Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Settings]]--
- local redstoneOutputSide = "right"
- local rednetModemSide = "top"
- local energyCellLowName = "cofh_thermalexpansion_energycell_0"
- local energyCellHightName = "cofh_thermalexpansion_energycell_1"
- local lowStoragePercentage = 10
- local hightStoragePercentage = 90
- --Don't edit from here on
- --[[Variables]]--
- local debugSetting = true
- local modeFileLoc = "mode"
- local cellLow = peripheral.wrap(energyCellLowName)
- local cellHight = peripheral.wrap(energyCellHightName)
- rednet.open(rednetModemSide)
- local modeFile
- --[[Functions]]--
- function printBoolean(boolean)
- if term.isColor() then
- if boolean then
- term.setTextColor(colors.lime)
- else
- term.setTextColor(colors.red)
- end
- end
- print(boolean)
- if term.isColor() then
- term.setTextColor(colors.white)
- end
- end
- function toBoolean(data)
- return not not data
- end
- function round(number)
- return math.floor(tonumber(number)+0.5)
- end
- --[[Code]]--
- if fs.exists(modeFileLoc) then
- modeFile = fs.open(modeFileLoc, "r")
- mode = toBoolean(modeFile.readAll())
- modeFile.close()
- else
- modeFile = fs.open(modeFileLoc, "w")
- modeFile.write("true")
- modeFile.close()
- shell.run("clear")
- print([[Energy cell maintain program
- Disigned specifficly for Divey1130 ( https://www.youtube.com/channel/UCk0BV_fHvw791r-ReeRXhEA )
- Yes I'm a big fan ;)
- Press any key to continue...]])
- os.pullEvent("key")
- end
- while true do
- local lowValue = cellLow.getEnergyStored("top")
- local lowMax = cellLow.getMaxEnergyStored("top")
- local lowPercentage = 100*lowValue/lowMax
- local highValue = cellHight.getEnergyStored("top")
- local highMax = cellHight.getMaxEnergyStored("top")
- local highPercentage = 100*highValue/highMax
- shell.run("clear")
- print("Energy cell 1 (low) : "..lowValue.." / "..lowMax.." ("..round(lowPercentage).."%)")
- print("Energy cell 2 (high): "..highValue.." / "..highMax.." ("..round(highPercentage).."%)")
- print()
- if lowPercentage < lowStoragePercentage then
- mode = true
- end
- if highPercentage > hightStoragePercentage then
- mode = false
- end
- modeFile = fs.open(modeFileLoc, "w")
- modeFile.write(mode)
- modeFile.close()
- rs.setOutput(redstoneOutputSide, toBoolean(mode))
- term.write("Redstone output: ")
- printBoolean(rs.getOutput(redstoneOutputSide))
- if debugSetting then
- print("highPercentage: "..highPercentage)
- print("highMax: "..highMax)
- print("highValue : "..highValue)
- print("hightStoragePercentage: "..hightStoragePercentage)
- print("lowPercentage: "..lowPercentage)
- print("lowMax: "..lowMax)
- print("lowValue : "..lowValue)
- print("lowStoragePercentage: "..lowStoragePercentage)
- print("mode: "..tostring(mode))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment