SHARE
TWEET

Untitled

AsTio Jun 20th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local cube = peripheral.wrap("ultimate_energy_cube_0")
  2.  
  3. function getEnergy()
  4.     local amount = cube.getEnergyStored()         -- save the energy amount in variable
  5.     local capacity = cube.getMaxEnergyStored()    -- save the total amount in your cube in a variable
  6.     return math.floor((amount/capacity)*100)      -- returns how much that is in percent, and floors the value removing decimals
  7. end
  8.  
  9. print (cube.getEnergyStored())
  10.  
  11. while true do
  12.     local energy = getEnergy()                    -- save the percent in a variable so you only calculate that once every time
  13.     if energy < 10 then                           -- if its less than 10% in your cube start reactor
  14.         print("1")
  15.     elseif energy > 95 then                       -- else if its greater than 95% stop your reactor
  16.         print("2)
  17.     end
  18.     sleep(3)                                      -- then sleep for 3 seconds and do everything again.
  19. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top