Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local e_cell = peripheral.wrap("left")
- local redstone_side = "right"
- local stored = 0
- local prevStored = 0
- local percentage = 0
- local status = "Idle"
- local function setStored()
- stored = e_cell.getEnergyStored()
- end
- local function check()
- setStored()
- if (stored == 0) then
- percentage = 0
- else
- percentage = stored / e_cell.getMaxEnergyStored()
- end
- if (0.9 <= percentage) then
- status = "Idle"
- rs.setOutput(redstone_side, false)
- elseif (0.2 >= percentage) then
- status = "Generating"
- rs.setOutput(redstone_side, true)
- end
- end
- local function displayStatus()
- term.clear()
- term.setCursorPos(1,1)
- print(" Status: "..status)
- if (stored == 0) then
- print("Energy Cell: 0%")
- else
- print("Energy Cell: "..math.floor(((percentage * 100) * 100) / 100).."%")
- end
- end
- while true do
- check()
- displayStatus()
- prevStored = stored
- os.sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement