Advertisement
fames

reactor

Dec 22nd, 2024
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.00 KB | None | 0 0
  1. ReactorObj = {}
  2.  
  3. function ReactorObj:new()
  4.     local obj = obj or {}
  5.     setmetatable(obj, {__index = self})
  6.  
  7.     obj.reacBig    = peripheral.find("BigReactors-Reactor") or nil
  8.     obj.reacBigger = peripheral.find("BiggerReactors_Reactor") or nil
  9.  
  10.     if obj.reacBig then
  11.         obj.mod = "BIG"
  12.     elseif obj.reacBigger then
  13.         obj.mod = "BIGGER"
  14.     else
  15.         obj.mod = "NONE"
  16.     end
  17.     return obj
  18. end
  19.  
  20. function ReactorObj:modType()
  21.     --return the modtype used (BIG or BIGGER)
  22.     return self.mod
  23. end
  24.  
  25. function ReactorObj:connected()
  26.     -- return true if a reactor is connected/valid
  27.     if self.reacBig or self.reacBigger then return true end
  28. end
  29.  
  30. function ReactorObj:setActive(foo)
  31.     if self.mod == "BIG" then
  32.         self.reacBig.setActive(foo or false)
  33.     elseif self.mod == "BIGGER" then
  34.         self.reacBigger.setActive(foo or false)
  35.     else
  36.         return 0
  37.     end
  38. end
  39.  
  40. function ReactorObj:getActive()
  41.     if self.mod == "BIG" then
  42.         return self.reacBig.getActive()
  43.     elseif self.mod == "BIGGER" then
  44.         return "NOT DONE"
  45.     else
  46.         return 0
  47.     end
  48. end
  49.  
  50.  
  51. function ReactorObj:setRods(foo)
  52.     if self.mod == "BIG" then
  53.         self.reacBig.setAllControlRodLevels((100-foo) or 100)
  54.     elseif self.mod == "BIGGER" then
  55.         self.reacBigger.setAllControlRodLevels((100-foo) or 100)
  56.     else
  57.         return 0
  58.     end
  59. end
  60.  
  61. function ReactorObj:getFlow()
  62.     if self.mod == "BIG" then
  63.         return self.reacBig.getHotFluidStats().fluidProducedLastTick
  64.     elseif self.mod == "BIGGER" then
  65.         return self.reacBigger.coolantTank().maxTransitionedLastTick()
  66.     else
  67.         return 0
  68.     end
  69. end
  70.  
  71. function ReactorObj:getRodLevel(num)
  72.     if self.mod == "BIG" then
  73.         return self.reacBig.getControlRodLevel(num or 0)
  74.     elseif self.mod == "BIGGER" then
  75.         return self.reacBigger.getControlRod(num or 0).level()
  76.     else
  77.         return 0
  78.     end
  79. end
  80.  
  81. function ReactorObj:getRodCount()
  82.         if self.mod == "BIG" then
  83.         return (table.getn(self.reacBig.getControlRodsLevels())+1)
  84.     elseif self.mod == "BIGGER" then
  85.         return "NOT DONE"
  86.     else
  87.         return 0
  88.     end
  89. end
  90.  
  91. function ReactorObj:getTankAmount()
  92.     if self.mod == "BIG" then
  93.         return self.reacBig.getHotFluidStats().fluidAmount
  94.     elseif self.mod == "BIGGER" then
  95.         return "NOT DONE"
  96.     else
  97.         return 0
  98.     end
  99. end
  100.  
  101. function ReactorObj:getTankCapacity()
  102.     if self.mod == "BIG" then
  103.         return self.reacBig.getHotFluidStats().fluidCapacity
  104.  
  105.     elseif self.mod == "BIGGER" then
  106.         return "NOT DONE"
  107.     else
  108.         return 0
  109.     end
  110. end
  111.  
  112. function ReactorObj:getFuelUsage()
  113.     if self.mod == "BIG" then
  114.         return self.reacBig.getFuelConsumedLastTick()
  115.     elseif self.mod == "BIGGER" then
  116.         return "NOT DONE"
  117.     else
  118.         return 0
  119.     end
  120. end
  121.  
  122. function ReactorObj:getEnergyStored()
  123.     if self.mod == "BIG" then
  124.         return self.reacBig.getEnergyStored()
  125.     elseif self.mod == "BIGGER" then
  126.         return "NOT DONE"
  127.     else
  128.         return 0
  129.     end
  130. end
  131.  
  132. function ReactorObj:getEnergyProduced()
  133.     if self.mod == "BIG" then
  134.         return self.reacBig.getEnergyProducedLastTick()
  135.     elseif self.mod == "BIGGER" then
  136.         return "NOT DONE"
  137.     else
  138.         return 0
  139.     end
  140. end
  141.  
  142. function ReactorObj:getEnergyCapacity()
  143.     if self.mod == "BIG" then
  144.         return self.reacBig.getEnergyCapacity()
  145.     elseif self.mod == "BIGGER" then
  146.         return "NOT DONE"
  147.     else
  148.         return 0
  149.     end
  150. end
  151.  
  152. function ReactorObj:getSize()
  153.     if self.mod == "BIG" then
  154.         local max = self.reacBig.mbGetMaximumCoordinate()
  155.         local min = self.reacBig.mbGetMinimumCoordinate()
  156.         local x = (max[1] - min[1]) +1
  157.         local y = (max[2] - min[2]) +1
  158.         local z = (max[3] - min[3]) +1
  159.         return x, y, z
  160.  
  161.     elseif self.mod == "BIGGER" then
  162.         return "NOT DONE"
  163.     else
  164.         return 0
  165.     end
  166. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement