Advertisement
rjtwins

mc_extreme_reactor_simple_controller

Aug 21st, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. --#requires
  2. local term = require("term")
  3. local component = require("component")
  4. local event = require("event")
  5.  
  6. --#variables
  7. local reactor = nil
  8. local running = true
  9. local energy = 0
  10. local maxEnergy = 10000000
  11.  
  12. --#main
  13. function main()
  14.   reactor = component.br_reactor
  15.   event.listen("touch",listen)
  16.   component.gpu.setResolution(25, 25)
  17.   while running do
  18.     energy = reactor.getEnergyStored()
  19.     if energy/maxEnergy > 0.75 then
  20.         reactor.setActive(false)
  21.     end
  22.     if energy/maxEnergy < 0.25 then
  23.         reactor.setActive(true)
  24.     end
  25.     term.clear()
  26.     print("Status: ", reactor.getActive())
  27.     print("Storage: ", energy)
  28.     print("Charge: ", math.floor((energy/maxEnergy)*100),"%")
  29.     os.sleep(.25)
  30.   end
  31. end
  32.  
  33. --#listen
  34. function listen(name,address,x,y,button,player)
  35.   running = false
  36. end
  37.  
  38. --#init
  39. main()
  40. component.gpu.setResolution(150, 50)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement