Advertisement
william200027

reactor glass

Apr 15th, 2020 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. --------Variable----------
  2. side = "bottom"
  3. Max = 10000000
  4. temp = 1
  5. Reactor = peripheral.wrap(side)
  6. Glasse = peripheral.wrap("top")
  7. width = 100
  8. storageUnit = {}
  9.  
  10. --------------------------
  11.  
  12. storageUnit["bar"] = Glasse.addBox(4,14,0,5,0xCC0000,0.9)
  13. storageUnit["bar"].setZ(2)
  14.  
  15. --------Programs----------
  16. function check()
  17.  ReactorEnergy = Reactor.getEnergyStored()
  18.  Pourcent = ReactorEnergy / Max * 100
  19. end
  20.  
  21. function OnOff()
  22.   if Pourcent > 80 then
  23.     Reactor.setActive(false)
  24.   elseif Pourcent < 20 then
  25.     Reactor.setActive(true)
  26.   end
  27. end
  28.  
  29. function GlasseTerminal()
  30.   storageUnit["bar"].setWidth(width / Max * ReactorEnergy)
  31.   Glasse.addText(10,25,ReactorEnergy.."/"..Max.." : "..Pourcent)
  32.   Glasse.sync()
  33. end
  34.  
  35. while true do
  36.   check()
  37.   OnOff()
  38.   GlasseTerminal()
  39.   print(ReactorEnergy.." / "..Max.." : "..Pourcent)
  40.   sleep(temp)
  41. end
  42. --------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement