Advertisement
Guest User

reactor

a guest
Dec 4th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.81 KB | None | 0 0
  1. reactor = peripheral.wrap("BigReactors-Reactor_0")
  2. checks = 0
  3. check = {}
  4. avg = "Not Determined"
  5. wastedNRG = 0
  6. forceTog = false
  7. while true do
  8.   parallel.waitForAny(function()
  9. while true do
  10.   if checks < 3 then
  11.     table.insert(check,reactor.getEnergyProducedLastTick())
  12.     checks = checks + 1
  13.   else
  14.     avg = tostring((check[1] + check[2] + check[3]) / 3)
  15.     checks = 0
  16.     check = {}
  17.   end
  18.   sleep(0)
  19.   term.setBackgroundColor(colors.purple)
  20.   term.clear()
  21.   term.setCursorPos(1,1)
  22.   term.setTextColor(colors.black)
  23.   write("Is active?: ")
  24.   if reactor.getActive() == true then
  25.     term.setTextColor(colors.lime)
  26.   elseif reactor.getActive() == false then
  27.     term.setTextColor(colors.red)
  28.   else
  29.     term.setTextColor(colors.blue)
  30.   end
  31.   print(tostring(reactor.getActive()))
  32.   term.setTextColor(colors.black)
  33.   write("Energy In Buffer: "..tostring(reactor.getEnergyStored()).."RF/10000000RF  "..string.sub(tostring((reactor.getEnergyStored()/10000000) * 100),1,string.find((reactor.getEnergyStored() / 10000000) * 100, ".") + 3).."%")
  34.   paintutils.drawLine(1,3,10,3,colors.brown)
  35.   paintutils.drawLine(0,3,(reactor.getEnergyStored() / 10000000)*10,3,colors.red)
  36.   term.setCursorPos(1,4)
  37.   term.setBackgroundColor(colors.purple)
  38.   print("Fuel: "..tostring(reactor.getFuelAmount()).."/"..tostring(reactor.getFuelAmountMax()).."mB  "..tostring((reactor.getFuelAmount()/reactor.getFuelAmountMax())*100).."%")
  39.   paintutils.drawLine(1,5,10,5,colors.black)
  40.   paintutils.drawLine((reactor.getFuelAmount() / reactor.getFuelAmountMax()) * 10,5,((reactor.getFuelAmount() / reactor.getFuelAmountMax())*10)+((reactor.getWasteAmount() / reactor.getFuelAmountMax())*10),5,colors.blue)              
  41.   paintutils.drawLine(0,5,(reactor.getFuelAmount() / reactor.getFuelAmountMax()) * 10,5,colors.yellow)
  42.   term.setBackgroundColor(colors.purple)
  43.   term.setCursorPos(1,6)
  44.   print("Average RF/t: "..avg)
  45.   if forceTog == false then
  46.     if reactor.getEnergyStored() >= 9000000 then
  47.       forceTog = true
  48.       reactor.setActive(false)
  49.     else
  50.       forceTog = false
  51.       reactor.setActive(true)
  52.     end
  53.   end
  54.   if reactor.getEnergyStored() == 10000000 then
  55.     wastedNRG = wastedNRG + reactor.getEnergyProducedLastTick()
  56.   end
  57.   print("Energy wasted: "..wastedNRG.."RF")
  58.   paintutils.drawLine(29,5,29,7,colors.blue)
  59.   paintutils.drawLine(30,8,32,8,colors.blue)
  60.   paintutils.drawLine(33,7,33,5,colors.blue)
  61.   paintutils.drawLine(31,6,31,4,colors.blue)
  62.   term.setCursorPos(29,9)
  63.   term.setBackgroundColor(colors.purple)
  64.   print("Manual Toggle: "..tostring(forceTog))
  65.   if forceTog == true then
  66.     paintutils.drawPixel(29,10,colors.lime)
  67.   else
  68.     paintutils.drawPixel(29,10,colors.red)
  69.   end
  70.   if reactor.getWasteAmount() >= 1000 then
  71.     reactor.doEjectWaste()
  72.   end
  73. end
  74. end, function()
  75. while true do
  76.   sleep(0)
  77.   local event, button, x, y = os.pullEvent()
  78.   if event == "mouse_click" then
  79.     if button == 1 then
  80.       if y >= 4 and y <= 8 and x >= 29 and x <= 33 then
  81.         if forceTog == true then
  82.           if reactor.getActive() == true then
  83.             reactor.setActive(false)
  84.           else
  85.             reactor.setActive(true)
  86.           end
  87.         end
  88.         break
  89.       elseif y == 10 and x == 29 then
  90.         if forceTog == false then
  91.           forceTog = true
  92.         else
  93.           forceTog = false
  94.         end
  95.         break
  96.       end
  97.     end
  98.   elseif event == "monitor_touch" then
  99.     if y >= 4 and y <=8 and x >= 29 and x <= 33 then
  100.       if reactor.getActive() == true then
  101.         reactor.setActive(false)
  102.       elseif reactor.getActive() == false then
  103.         reactor.setActive(true)
  104.       end
  105.       break
  106.     elseif y == 10 and x == 29 then
  107.       if forceTog == true then
  108.         forceTog = false
  109.       else
  110.         forceTog = true
  111.       end
  112.       break
  113.     end
  114.   end
  115. end
  116. end)
  117. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement