Advertisement
Tanner235

reactor_gui

Sep 28th, 2022 (edited)
1,229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. local mon = peripheral.wrap("right")
  2. local reactor = peripheral.wrap("BiggerReactors_Reactor_1")
  3.  
  4. function clear()
  5.     mon.setBackgroundColor(colors.black)
  6.     mon.clear()
  7. end
  8.  
  9. function draw_text(x, y, text, text_color, bg_color)
  10.     mon.setBackgroundColor(bg_color)
  11.     mon.setTextColor(text_color)
  12.     mon.setCursorPos(x, y)
  13.     mon.write(text)
  14. end
  15.  
  16. function running()
  17.     if reactor.active() == true then
  18.         return "ONLINE"
  19.     elseif reactor.active() == false then
  20.         return "OFFLINE"
  21.     end
  22. end
  23.  
  24. function running_color()
  25.     if reactor.active() == true then
  26.         return colors.green
  27.     elseif reactor.active() == false then
  28.         return colors.red
  29.     end
  30. end
  31.  
  32. function buffer()
  33.     if math.floor((reactor.battery().stored()/reactor.battery().capacity()) * 100) <= 10 then
  34.         reactor.setActive(true)
  35.     end
  36.  
  37.     if math.floor((reactor.battery().stored()/reactor.battery().capacity()) * 100) >= 90 then
  38.         reactor.setActive(false)
  39.     end
  40. end
  41.  
  42. while true do
  43.     clear()
  44.     draw_text(2, 2, "Power: ", colors.yellow, colors.black)
  45.     draw_text(10, 2, running(), running_color(), colors.black)
  46.     draw_text(2, 4, "RF/tick:  ".. reactor.battery().producedLastTick(), colors.yellow, colors.black)
  47.     draw_text(2, 6, "Stored (RF):  ".. math.floor((reactor.battery().stored()/reactor.battery().capacity()) * 100) .."%", colors.yellow, colors.black)
  48.     sleep(2)
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement