Advertisement
red2211

ic_reactor_oc_v2

Apr 9th, 2021 (edited)
1,043
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.58 KB | None | 0 0
  1. --components
  2. local component = require("component")
  3. local event = require("event")
  4. local term = require("term")
  5. local fs = require("filesystem")
  6. local sides = require("sides")
  7. local colors = require("colors")
  8. local computer = require("computer")
  9.  
  10. local gpu = component.gpu
  11. local reactor = component.reactor_chamber
  12. local rs = component.redstone
  13. local w,h = gpu.getResolution()
  14. --components
  15.  
  16. --colors
  17. local black = 0x000000
  18. local red = 0xFF0000
  19. local yellow = 0xFFFF00
  20. local white = 0xffffff
  21. --colors
  22.  
  23. --variables
  24. local color = red
  25. --variables
  26.  
  27. --functions
  28.  
  29. --centre text
  30. local function centerF(row, msg, ...)
  31.     local mLen = string.len(msg)
  32.     w, h = gpu.getResolution()
  33.     term.setCursor((w - mLen)/2,row)
  34.     print(msg:format(...))
  35. end
  36. --centre text
  37.  
  38. --reactor status
  39. local function status()
  40.     if reactor.getReactorEUOutput() == 0 then
  41.         return "OffLine"
  42.     else
  43.         return "OnLine"
  44.     end
  45. end
  46. --reactor status
  47.  
  48. --reactor max heat
  49. local function maxHeat()
  50.     max_heat = reactor.getMaxHeat() / 100
  51.     max_heat_r = math.floor(max_heat + .5)
  52.     return max_heat_r
  53. end
  54. --reactor max heat
  55.  
  56. --reactor get heat
  57. local function getHeat()
  58.     curr_heat = reactor.getHeat() / reactor.getMaxHeat() * 100
  59.     curr_heat_r = math.floor(curr_heat + .5)
  60.     return curr_heat_r
  61. end
  62. --reactor get heat
  63.  
  64. --reactor EU  
  65. local function getEU()
  66.     euout = reactor.getReactorEUOutput()
  67.     euout_r = math.floor(euout + .5)
  68.     return euout_r
  69. end
  70. --reactor EU
  71.  
  72. --measurements
  73. local function measurements()
  74.     centerF(28, string.format("Reactor is: %s", status()))
  75.     centerF(29, string.format("Reactor maxheat: %s", maxHeat()))
  76.     centerF(30, string.format("Reactor heat: %s", getHeat()))
  77.     centerF(31, string.format("Reactor EU Output: %s", getEU()))    
  78.     os.sleep(1)
  79. end
  80. --measurements
  81.  
  82. --hazard
  83. local function hazard()
  84.     term.clear()
  85.        
  86.     centerF(4, "                      -omNMy`                                          `yNd+.                       ")
  87.     centerF(5, "                   `+dNMMMMMh`                                        `hMMMMNh/`                    ")
  88.     centerF(6, "                 .smMMMMMMMMMd.                                      .dMMMMMMMMmo`                  ")
  89.     centerF(7, "               .sNMMMMMMMMMMMMm-                                    -mMMMMMMMMMMMmo`                ")
  90.     centerF(8, "             `oNMMMMMMMMMMMMMMMN/                                  :mMMMMMMMMMMMMMMm+`              ")
  91.     centerF(9, "            :dMMMMMMMMMMMMMMMMMMN+                                /NMMMMMMMMMMMMMMMMMh-             ")
  92.     centerF(10, "          `sNMMMMMMMMMMMMMMMMMMMMMo`                             +NMMMMMMMMMMMMMMMMMMMN+            ")
  93.     centerF(11, "         .hMMMMMMMMMMMMMMMMMMMMMMMMy`                           oNMMMMMMMMMMMMMMMMMMMMMMy`          ")
  94.     centerF(12, "        -mMMMMMMMMMMMMMMMMMMMMMMMMMMh.                        `sMMMMMMMMMMMMMMMMMMMMMMMMMh.         ")
  95.     centerF(13, "       -mMMMMMMMMMMMMMMMMMMMMMMMMMMMMd.                      `yMMMMMMMMMMMMMMMMMMMMMMMMMMMd.        ")
  96.     centerF(14, "      .mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMm:                    `hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMh`       ")
  97.     centerF(15, "     `dMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN/                  .dMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy       ")
  98.     centerF(16, "     sMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN+                -dMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM/      ")
  99.     centerF(17, "    -NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNh.      `       .dMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMm`     ")
  100.     centerF(18, "    yMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMmo.  `-+syhhhys/-`  -sNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMo     ")
  101.     centerF(19, "   .NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMs.  -smMMMMMMMMMMMdo.  -hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMm`    ")
  102.     centerF(20, "   oMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM+  `sMMMMMMMMMMMMMMMMNo   sMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM:    ")
  103.     centerF(21, "   hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMo  `dMMMMMMMMMMMMMMMMMMMy   hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMo    ")
  104.     centerF(22, "   mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN`  yMMMMMMMMMMMMMMMMMMMMM+  -MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy    ")
  105.     centerF(23, "   NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy  `NMMMMMMMMMMMMMMMMMMMMMd   mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMd    ")
  106.     centerF(24, "   +oooooooooooooooooooooooooooooo:  `NMMMMMMMMMMMMMMMMMMMMMd   ................................    ")
  107.     centerF(25, "                                      hMMMMMMMMMMMMMMMMMMMMMo                                       ")
  108.     centerF(26, "                                      .mMMMMMMMMMMMMMMMMMMMh`                                       ")
  109.     centerF(27, "                                       .hMMMMMMMMMMMMMMMMMs`                                        ")
  110.     centerF(28, "                                         :hNMMMMMMMMMMMNy-                                          ")
  111.     centerF(29, "                                           `/sydmmdhyo:`                                            ")
  112.     centerF(30, "                                         //.   ````    ./+                                          ")
  113.     centerF(31, "                                       `sMMNmhso+++oshmNMMy`                                        ")
  114.     centerF(32, "                                      `yMMMMMMMMMMMMMMMMMMMy`                                       ")
  115.     centerF(33, "                                     .dMMMMMMMMMMMMMMMMMMMMMh`                                      ")
  116.     centerF(34, "                                    -mMMMMMMMMMMMMMMMMMMMMMMMd.                                     ")
  117.     centerF(35, "                                   :NMMMMMMMMMMMMMMMMMMMMMMMMMd.                                    ")
  118.     centerF(36, "                                  +NMMMMMMMMMMMMMMMMMMMMMMMMMMMm-                                   ")
  119.     centerF(37, "                                 oNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN:                                  ")
  120.     centerF(38, "                               `sMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN/                                 ")
  121.     centerF(39, "                              `hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN+                                ")
  122.     centerF(40, "                             .dMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM+                               ")
  123.     centerF(41, "                            -mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMo                              ")
  124.     centerF(42, "                           :NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMs`                            ")
  125.     centerF(43, "                          +NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy`                           ")
  126.     centerF(44, "                         `smNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNd:                           ")
  127.     centerF(45, "                            -/ymNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNds/.                             ")
  128.     centerF(46, "                                .:+shmNNMMMMMMMMMMMMMMMMMMMNNmhs/-`                                 ")
  129.     centerF(47, "                                      `.:/++osyyyyyyyso+/:-.`                                       ")
  130.     gpu.setForeground(red)
  131.     centerF(49, "IC2 Reactor Controller")
  132.     centerF(50, "by red2211")
  133.    
  134.     os.sleep(2)
  135. end
  136. --hazard
  137.  
  138. --main text
  139. local function main_text()
  140.     term.clear()
  141.    
  142.     gpu.setForeground(white)
  143.    
  144.     centerF(11, "d888888b  .o88b. .d888b.      d8888b. d88888b  .d8b.   .o88b. d888888b  .d88b.  d8888b.")
  145.     centerF(12, "  `88'   d8P  Y8 VP  `8D      88  `8D 88'     d8' `8b d8P  Y8 `~~88~~' .8P  Y8. 88  `8D")
  146.     centerF(13, "   88    8P         odD'      88oobY' 88ooooo 88ooo88 8P         88    88    88 88oobY'")
  147.     centerF(14, "   88    8b       .88'        88`8b   88~~~~~ 88~~~88 8b         88    88    88 88`8b  ")
  148.     centerF(15, "  .88.   Y8b  d8 j88.         88 `88. 88.     88   88 Y8b  d8    88    `8b  d8' 88 `88.")
  149.     centerF(16, "Y888888P  `Y88P' 888888D      88   YD Y88888P YP   YP  `Y88P'    YP     `Y88P'  88   YD")
  150.    
  151.     centerF(18, " .o88b.  .d88b.  d8b   db d888888b d8888b.  .d88b.  db      db      d88888b d8888b.")
  152.     centerF(19, "d8P  Y8 .8P  Y8. 888o  88 `~~88~~' 88  `8D .8P  Y8. 88      88      88'     88  `8D")
  153.     centerF(20, "8P      88    88 88V8o 88    88    88oobY' 88    88 88      88      88ooooo 88oobY'")
  154.     centerF(21, "8b      88    88 88 V8o88    88    88`8b   88    88 88      88      88~~~~~ 88`8b  ")
  155.     centerF(22, "Y8b  d8 `8b  d8' 88  V888    88    88 `88. `8b  d8' 88booo. 88booo. 88.     88 `88.")
  156.     centerF(23, " `Y88P'  `Y88P'  VP   V8P    YP    88   YD  `Y88P'  Y88888P Y88888P Y88888P 88   YD")
  157. end
  158. --main text
  159.  
  160. --warning_tr
  161. local function warning_tr()
  162.     term.clear()
  163.  
  164.     gpu.setForeground(red)
  165.     centerF(4, "                                            `:oydddhs/`                                             ")
  166.     centerF(5, "                                          `oNMMMMMMMMMMy                                            ")
  167.     centerF(6, "                                         :NMMMms///ohMMMMo`                                         ")
  168.     centerF(7, "                                        /MMMMo       :mMMMh`                                        ")
  169.     centerF(8, "                                      `oMMMN/          hMMMm.                                       ")
  170.     centerF(9, "                                     `yMMMm:            sMMMN:                                      ")
  171.     centerF(10, "                                    .dMMMh               +MMMM/                                     ")
  172.     centerF(11, "                                    mMMMy                 /NMMMo`                                   ")
  173.     centerF(12, "                                  :NMMMo                   :mMMMy`                                  ")
  174.     centerF(13, "                                 +MMMN+                      dMMMd.                                 ")
  175.     centerF(14, "                               `sMMMm:                        yMMMm                                 ")
  176.     centerF(15, "                              `hMMMd                           oMMMN:                               ")
  177.     centerF(16, "                             .mMMMh                             +NMMM+                              ")
  178.     centerF(17, "                             NMMMs                               /NMMMs`                            ")
  179.     centerF(18, "                           /MMMM+                                 :mMMMy`                           ")
  180.     centerF(19, "                          oMMMN/                                    hMMMd.                          ")
  181.     centerF(20, "                        `yMMMm:                                      yMMMm                          ")
  182.     centerF(21, "                       `dMMMd                                         oMMMN:                        ")
  183.     centerF(22, "                       mMMMy                                           +NMMM+                       ")
  184.     centerF(23, "                     :NMMMo                                             /NMMMs`                     ")
  185.     centerF(24, "                    +MMMN+                                               :mMMMh`                    ")
  186.     centerF(25, "                  `sMMMm:                                                  hMMMd.                   ")
  187.     centerF(26, "                 `hMMMd                                                     yMMMm                   ")
  188.     centerF(27, "                .dMMMh                                                       oMMMN:                 ")
  189.     centerF(28, "                NMMMs                                                         +NMMM+                ")
  190.     centerF(29, "              /NMMM+                                                           /NMMMs`              ")
  191.     centerF(30, "             oMMMN/                                                             :mMMMh`             ")
  192.     centerF(31, "           `yMMMm:                                                                hMMMd.            ")
  193.     centerF(32, "          `hMMMd                                                                   yMMMm            ")
  194.     centerF(33, "         .mMMMy                                                                     oMMMN:          ")
  195.     centerF(34, "        :NMMMo                                                                       +NMMM+         ")
  196.     centerF(35, "       /MMMN+                                                                         /NMMMs`       ")
  197.     centerF(36, "      oMMMm:                                                                           :mMMMy`      ")
  198.     centerF(37, "      MMMN:                                                                              hMMMh`     ")
  199.     centerF(38, "     +MMMy                                                                                dMMM/     ")
  200.     centerF(39, "     .NMMN/                                                                               hMMM+     ")
  201.     centerF(40, "      /NMMMy:                                                                           :sMMMN.     ")
  202.     centerF(41, "        dMMMMNdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddmMMMMd       ")
  203.     centerF(42, "         :smMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMmy:        ")
  204. end
  205. --warning_tr
  206. local function warning_fr()
  207.     gpu.setForeground(color)
  208.    
  209.     centerF(15, "     /d         ")
  210.     centerF(16, "     yMo        ")
  211.     centerF(17, "     hMMy       ")
  212.     centerF(18, "      y:  dMMMm/          ")
  213.     centerF(19, "      NMo NMMMMMo  h:     ")
  214.     centerF(20, "      mMMmMMMMMMM/+MN:    ")
  215.     centerF(21, "      MMMMMMMMMMMmmMMd    ")
  216.     centerF(22, " :   +MMMMMMMMMMMMMMMMo   ")
  217.     centerF(23, "    dh  dMMMMMMMMMMMMMMMMN   /  ")
  218.     centerF(24, "    dMm+MMMMMMMMMMMMMMMMMMo yM/ ")
  219.     centerF(25, "    mMMMMMMMMMMMMhNMMMMMMMmhMMd ")
  220.     centerF(26, "    MMMMMMMMMMMMMo:NMMMMMMMMMMN ")
  221.     centerF(27, " o +MMMMMMMMMMMMMs /MMMMMMMMMMN ")
  222.     centerF(28, " NNmMMMMmMMMmMMMMo  mMMmMMMMMMd ")
  223.     centerF(29, " MMMMMMm NMd mMMM   dMy:MMMMMM: ")
  224.     centerF(30, ":MMMMMMy yMs :mMo   s/  NMMMMm:h")
  225.     centerF(31, ":MMMMyh+  Ns   /       :omMMMMMM")
  226.     centerF(32, " MMMM+    :d             NMMMMMm")
  227.     centerF(33, " hMMMd      :           hMMMMMM/")
  228.     centerF(34, "  mMMMy               :dMMMMMN/ ")
  229.     centerF(35, "   yMMMh:           /yMMMMMms   ")
  230.     centerF(36, "    :ymMMh+      +ymMMNmhs/     ")
  231.     centerF(37, "    :++osssso+++++oooo+++++     ")
  232.     centerF(38, "     //////////////////////     ")
  233.     centerF(44, "Reactor Overheated")
  234.     centerF(45, "Explosion risk")
  235.     centerF(46, "Turning off reactor...")
  236.     computer.beep(500)
  237.     os.sleep(1)
  238.     color = color==red and yellow or red
  239. end
  240. --warning_fr
  241.  
  242. --warning_fr
  243. --functions
  244.  
  245. hazard()
  246.  
  247. while true do
  248.     if getHeat() <= 50 then
  249.         rs.setOutput(sides.top, 15)
  250.         main_text()
  251.         measurements()
  252.    
  253.     elseif getHeat() >= 50 then
  254.         rs.setOutput(sides.top, 0)
  255.         warning_tr()
  256.         while getHeat() >= 50 do
  257.             warning_fr()
  258.         end
  259.     end    
  260.     gpu.setForeground(white)
  261. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement