Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- use an "Energy Sensor Kit" to right click on a Redstone Energy Cell
- -- put the card in a "Nuclear Information Reader"
- -- use this program in a computer to read the energy level
- -- the Nuclear Information Reader is on the left
- m = peripheral.wrap("left")
- local sleepTime = 20
- local stopEnginePercent = 95
- local startEnginePercent = 10
- while (true) do
- local current = 0
- local capacity = 0
- local percent = 0
- a,b,c,info = m.get(1)
- -- find the current energy level and max capacity
- for system, status in pairs(info) do
- if system == "energyL" then
- current = status
- else
- if system == "maxStorageL" then
- capacity = status
- end
- end
- end
- if capacity > 0 then
- percent = 100 * current / capacity
- print(tostring(current) .. " / " .. tostring(capacity) .. " (" .. tostring(percent) .. " %)")
- else
- print "Failed to read energy level"
- end
- if percent < startEnginePercent then
- -- turn on the engines
- print("Engines are on")
- redstone.setOutput("right", false)
- else
- if percent > stopEnginePercent then
- -- turn off the engines
- print("Engines are off")
- redstone.setOutput("right", true)
- else
- -- not changing the current state of the engines
- print("Engines continuing in current state")
- end
- end
- sleep(sleepTime)
- end
Advertisement
Add Comment
Please, Sign In to add comment