Advertisement
Nambarc

MC Reactor Monitor

Dec 29th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. local reactor = peripheral.wrap('back')
  2. local monitor = peripheral.wrap('top')
  3. local modem = peripheral.wrap('right')
  4.  
  5. while true do
  6.     monitor.clear()
  7.     monitor.setCursorPos(1,1)
  8.     monitor.write('Reactor Energy')
  9.     reactorEnergy = reactor.getEnergyStored()
  10.     reactorEnergyPercent = math.floor(reactorEnergy/100000)
  11.     modem.transmit(1,1,reactorEnergyPercent)
  12.     monitor.setCursorPos(1,2)
  13.     monitor.write(reactorEnergyPercent.."%")
  14.    
  15.     if reactorEnergyPercent < 20 then
  16.         reactor.setActive (true)
  17.     end
  18.     if reactorEnergyPercent > 80 then
  19.         reactor.setActive (false)
  20.     end
  21.    
  22.     if reactor.getActive() then
  23.         state = "ON"
  24.     else
  25.         state = "OFF"
  26.     end
  27.    
  28.     monitor.setCursorPos(1,3)
  29.     monitor.write("Reactor is "..state)
  30.    
  31.     sleep(1)
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement