Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local sides = require("sides")
- local term = require("term")
- local redstoneAddress = component.get("ace")
- local energyAddress = component.get("d78")
- local redstone = component.proxy(redstoneAddress)
- local energyCell = component.proxy(energyAddress)
- local energyPercent = (energyCell.getEnergyStored())/(energyCell.getMaxEnergyStored())*100
- local x = 0
- local y = 2 --Used for the power rate calculations
- local function powerRate()
- local a = energyCell.getEnergyStored()
- local b = energyCell.getEnergyStored()
- local c = (b-a)/20*y
- return(c)
- end
- term.clear()
- io.write("Power Controller v.1.0\n")
- os.sleep(1)
- term.clear()
- while true do
- if energyPercent > 75 and not (x == 1) then
- x = 1
- redstone.setOutput(sides.right,0)
- redstone.setOutput(sides.up,0)
- term.clear()
- term.setCursor(1,1)
- io.write("Too much power! shutting off generation.\n")
- elseif (25 < energyPercent) and (energyPercent <= 75) and not (x == 2) then
- x = 2
- redstone.setOutput(sides.right,15)
- redstone.setOutput(sides.up,0)
- term.clear()
- term.setCursor(1,1)
- io.write("Power is stabalized")
- elseif energyPercent <= 25 and not (x == 3) then
- x = 3
- redstone.setOutput(sides.right,15)
- redstone.setOutput(sides.up,15)
- term.clear()
- term.setCursor(1,1)
- io.write("Power is being built up!\n")
- end
- os.sleep(y)
- term.setCursor(1,2)
- term.clearLine()
- io.write("RF per tick :"..powerRate())
- end
Advertisement
Add Comment
Please, Sign In to add comment