Advertisement
Muzze77

NuclearElmos_Reactor

Oct 26th, 2024 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.40 KB | None | 0 0
  1. shell.run("clear")
  2. dbcol = colors.black
  3. dtcol = colors.lime
  4. diskR = ""
  5.  
  6.  
  7.  
  8. function mbut(cx,cy,text,bcol,tcol)
  9.     if bcol == nil then
  10.         bcol = dbcol
  11.     end
  12.     if tcol == nil then
  13.         tcol = dtcol
  14.     end
  15.     mon.setCursorPos(cx,cy)
  16.     mon.setBackgroundColor(bcol)
  17.     mon.setTextColor(tcol)
  18.     mon.write(text)
  19.     mon.setBackgroundColor(dbcol)
  20.     mon.setTextColor(dtcol)
  21. end
  22. function rows()
  23. mbut(2,y,"|")
  24. mbut(64,y,"|")
  25. mbut(33,y,"|")
  26.  
  27. end
  28.  
  29. state = false
  30. rs.setOutput("left",false)
  31. while true do
  32.  
  33.  
  34.  
  35. x = 2
  36. y = 2
  37.  
  38. machines = {}
  39. machines = peripheral.getNames()
  40.  
  41. mon = ""
  42. reactors = {}
  43.  
  44.  
  45. for v, k in pairs(machines) do
  46.  
  47.     if string.find(k,"monitor")  ~= nil then
  48.         mon = peripheral.wrap(k)
  49.         mon.setTextScale(0.5)
  50.    
  51.     end
  52.     if string.find(k,"reactor") ~= nil then
  53.         table.insert(reactors,k)
  54.        
  55.     end
  56.     if string.find(k,"chest_diamond") ~= nil then
  57.         chest = peripheral.wrap(k)
  58.         chestAPI = k
  59.     end
  60.     if string.find(k,"drive") ~= nil then
  61.         drive = peripheral.wrap(k)
  62.         driveAPI = k
  63.         function readDisk()
  64.             diskR = fs.open("disk/akw.lua","r")
  65.             if diskR == nil then
  66.                 create = fs.open("disk/akw.lua","w")
  67.                 create.write(false)
  68.                 create.close()
  69.             end
  70.             reading = diskR.readAll()
  71.             diskR.close()
  72.             return reading
  73.         end
  74.  
  75.         function saveDisk(text)
  76.             disk = fs.open("disk/akw.lua","w")
  77.             disk.write(text)
  78.             disk.close()
  79.         end    
  80.     end
  81.  
  82. end
  83.  
  84. sum = 0
  85. reactorsStats = {}
  86.  
  87. mbut(2,y,"Reactors: ")
  88.  
  89. y = 4
  90. mbut(2,y,"+------------------------------+------------------------------+")
  91. y = 5
  92. rows()
  93. y = 6
  94. for v,k in pairs(reactors) do
  95.     mod = v % 2
  96.     if mod == 0 then
  97.         x = 33
  98.         y = y - 5
  99.        
  100.     else
  101.         x = 2
  102.        
  103.     end
  104.     reactor = peripheral.wrap(k)
  105.     reactorAPI = k
  106.     reactorCore = reactor.getReactorCore()
  107.     data = reactorCore.getMetadata()
  108.     stats = data["reactor"]
  109.    
  110.     reactor_status = stats.active
  111.     reactor_heat = stats.heat
  112.     reactor_eu = stats.euOutput
  113.     reactor_maxHeat = stats.maxHeat
  114.    
  115.     eu = string.format("%d",reactor_eu)
  116.     sum = sum + eu
  117.     rows()
  118.     col = 0
  119.  if fs.exists("disk/akw.lua") == nil then
  120.      state = false
  121.      saveDisk(state)
  122.  else
  123.      state = readDisk()
  124.     if state == nil then
  125.         state = "false"
  126.         saveDisk(state)
  127.     end
  128.  end
  129.     if reactor_heat >= 2000 then
  130.             state = false
  131.             saveDisk(state)
  132.     end
  133.  
  134.     print(state)
  135.    
  136.     if state == "true"  then
  137.         rs.setOutput("top",true)
  138.         mbut(12,2,"[+]",colors.green)
  139.     elseif state == "false" or state == "nil" then
  140.         rs.setOutput("top",false)
  141.         mbut(12,2,"[-]",colors.red)
  142.     end
  143.    
  144.     if reactor_status == true then
  145.         reactor_status = "On"
  146.         col = colors.green
  147.     else   
  148.         reactor_status = "Off"
  149.         col = colors.red
  150.     end
  151.     mbut(x+1,y,"                      ")
  152.     mbut(x+2,y,"Reactor " .. v .. " Status " .. reactor_status,nil,col)
  153.     y = y + 1
  154.     rows()
  155.     mbut(x+1,y,"                      ")
  156.     mbut(x+2,y,"Reactor Heatlevel: " .. reactor_heat .. " / " .. reactor_maxHeat)
  157.     y = y + 1
  158.     rows()
  159.     mbut(x+1,y,"                      ")
  160.     mbut(x+2,y,"Reactor EU Output: " .. eu)
  161.     y = y + 1
  162.     rows()
  163.     y = y + 1
  164.     mbut(2,y,"+------------------------------+------------------------------+")
  165.     y = y + 1
  166.    
  167. end
  168. rows()
  169. mbut(4,y,"                      ")
  170. mbut(4,y,"Total EU/T: " .. sum, nil, colors.blue)
  171. y = y + 1
  172.  
  173.  
  174.  
  175.  
  176. mbut(2,y,"+------------------------------+------------------------------+")
  177. sleep(0.5)
  178.  
  179. end
  180.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement