Guest User

reactor

a guest
Jan 19th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. while true do
  2.   local r = peripheral.wrap("BigReactors-Reactor_0")
  3.   local mon = peripheral.wrap("monitor_0")
  4.   local reactorOnline = r.getActive()
  5.   local energyProduction = r.getEnergyProducedLastTick()
  6.   local energyStored = r.getEnergyStored()
  7.  
  8.   mon.clear()
  9.      
  10.   --Reactor Online
  11.   mon.setCursorPos(1,1)
  12.   mon.setTextColor(colors.white)
  13.   mon.write("Active: ")
  14.   if reactorOnline then
  15.     mon.setTextColor(colors.lime)
  16.   else
  17.     mon.setTextColor(colors.red)
  18.   end      
  19.   if reactorOnline then
  20.     mon.write("True")
  21.   else
  22.     mon.write("False")
  23.   end    
  24.  
  25.   --RF/t Production
  26.   mon.setCursorPos(1,2)
  27.   mon.setTextColor(colors.white)
  28.   mon.write("RF/t: ")
  29.   if energyProduction <= 0 then
  30.     mon.setTextColor(colors.red)
  31.   else  
  32.     mon.setTextColor(colors.lime)
  33.   end  
  34.   mon.write(math.floor(energyProduction).." RF/t")    
  35.  
  36.   --Energy Stored
  37.   mon.setCursorPos(1,3)
  38.   mon.setTextColor(colors.white)
  39.   mon.write("Energy Stored: ")
  40.   if energyStored < 1000000 then
  41.     mon.setTextColor(colors.red)
  42.   else
  43.     mon.setTextColor(colors.lime)
  44.   end  
  45.   mon.write(math.floor(energyStored).." RF")
  46.  
  47.   --Activation Button Display
  48.   if reactorOnline then
  49.     mon.setCursorPos(19,1)
  50.     mon.setTextColor(colors.red)
  51.   else
  52.     mon.setCursorPos(22,1)
  53.     mon.setTextColor(colors.lime)
  54.   end
  55.   if reactorOnline then
  56.     mon.write("De-Activate")
  57.   else
  58.     mon.write("Activate")
  59.   end    
  60.  
  61.   --Button Timer
  62.   local myTimer = os.startTimer(.05)
  63.   local event, side, x, y = os.pullEvent("monitor_touch")
  64.   if y == 1 and x < 30 and x > 19 and reactorOnline then
  65.     r.setActive(false)
  66.   elseif y == 1 and x < 30 and x > 22 then
  67.     r.setActive(true)
  68.   else
  69.     os.cancelTimer(myTimer)
  70.   end    
  71.    
  72. end
Advertisement
Add Comment
Please, Sign In to add comment