Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Config:
- batSide = "rftoolspower:cell3_1"
- batMods = "rftools"
- minCharge = 15
- maxCharge = 100
- outSide = "bottom"
- monSide = "monitor_0"
- -- Prog:
- --term.clear()
- bat = peripheral.wrap(batSide)
- if monSide ~= " " then
- mon = peripheral.wrap(monSide)
- end
- makeRF = false
- stateColor = colors.orange
- function monitor()
- prod = tostring(makeRF)
- mon.clear()
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.white)
- mon.write("Energy Storage")
- mon.setCursorPos(1,3)
- mon.write(energy.."/"..capacity.." RF")
- progressBar = math.ceil((percent*17)/100)
- if percent >= 0 and percent < 25 then
- progressColor = colors.red
- elseif percent >= 25 and percent < 50 then
- progressColor = colors.orange
- elseif percent >= 50 and percent < 75 then
- progressColor = colors.yellow
- elseif percent >= 75 and percent <= 100 then
- progressColor = colors.lime
- end
- mon.setCursorPos(1,5)
- mon.clearLine()
- for i = 0,progressBar do
- mon.setCursorPos(i,5)
- mon.setBackgroundColor(progressColor)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(dataColor)
- mon.write(" "..tostring(rate))
- mon.setTextColor(colors.white)
- mon.write(" RF/t")
- end
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(1,7)
- mon.write("Info:")
- mon.setCursorPos(1,8)
- mon.write(percent.."% (Need: "..needed.." RF)")
- mon.setCursorPos(1,9)
- mon.write("Production: ")
- mon.setTextColor(stateColor)
- mon.write(prod)
- end
- time_new = os.time()
- while true do
- time_old = time_new
- sleep(0.2)
- time_new = os.time()
- if batMods == "mekanism" then
- energy = bat.getTotalEnergy()
- capacity = bat.getTotalMaxEnergy()
- needed = bat.getTotalEnergyNeeded()
- percent = bat.getTotalEnergyFilledPercentage() *100
- elseif batMods == "rftools" then
- energy = bat.getEnergy()
- capacity = bat.getEnergyCapacity()
- needed = capacity - energy
- percent = math.ceil((energy*100)/capacity)
- end
- getEnergy_temp = energy
- --sleep(0)
- if batMods == "mekanism" then
- getEnergy = bat.getTotalEnergy()
- elseif batMods == "rftools" then
- getEnergy = bat.getEnergy()
- end
- time_delta = os.time() - time_old
- print(time_old)
- print(tonumber(os.time()))
- print(time_delta)
- rate = math.ceil(((getEnergy - getEnergy_temp)/time_delta)/1000)
- term.clear()
- term.setCursorPos(1,3)
- print("Energy Data: "..percent.."%")
- print(energy.."/"..capacity.." RF")
- print("Need: "..needed.." RF")
- if rate < 0 then
- dataColor = colors.red
- else
- dataColor = colors.lime
- end
- write("Rate: ")
- term.setTextColor(dataColor)
- write(rate)
- term.setTextColor(colors.white)
- print(" RF/t")
- if percent < minCharge then
- print("Current State: Generate Power ...")
- stateColor = colors.lime
- makeRF = true
- elseif percent >= maxCharge then
- print("Current State: Waiting ...")
- stateColor = colors.orange
- makeRF = false
- end
- monitor()
- if makeRF then
- rs.setOutput(outSide,true)
- else
- rs.setOutput(outSide,false)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement