r/ComputerCraft • • Jul 29 '14

Help with a program.

Hi, have posted here before but that was a while ago. Basically haven't used CC in a while and am having a very large brain fart. I'm looking to have a computer read the amount of energy in a redstone energy cell and if it hits like a 75% threshold turn my power gen on. And when it gets full shut it off. I know it would be an if then statement but I'm not sure how to write it :(

Any help would be great thanks

1 Upvotes

6 comments sorted by

View all comments

3

u/sjonky Jul 31 '14
energycell = peripheral.wrap("right") -- change side
amount = energycell.getEnergyStored("unknown")
capacity = energycell.getMaxEnergyStored("unknown")
energyPercent = (amount/capacity)*100
if energyPercent > 75 then
    -- turn power gen off
else
    -- turn power gen on
end

If you want to check out some of this in a video format, ive made some tutorials on openPeripheral stuff, https://www.youtube.com/watch?v=MAkKKDqYM3o in specific covers openPeripheral and energy storage stuff

1

u/Warmasher Jul 31 '14

O wow thanks, ill have to give this a try