Advertisement
Greygraphics

ReactorOS

Jan 9th, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.73 KB | None | 0 0
  1. if REACTOR == nil then
  2.     print("This program needs a specific startup file, take a look at the pastebin of this program (gtQsXi8j)")
  3. end
  4.  
  5.  
  6. local oldTerm
  7. local name = os.getComputerLabel()
  8. local cID = os.getComputerID()
  9.  
  10. local function wrap()
  11.     mon = peripheral.wrap("monitor_"..MONITOR)
  12.     mon.clear()
  13.     mon.setTextScale(MONSCALE)
  14.     w,h = term.getSize()
  15.     mw,mh = mon.getSize()
  16.     print("Wrapped monitor "..MONITOR)
  17.    
  18.     reactor = peripheral.wrap("BigReactors-Reactor_"..REACTOR)
  19.     print("Wrapped reactor "..REACTOR)
  20. end
  21.  
  22. local function conv(bInput,ifYes,ifNo)
  23.     if bInput == true then
  24.         return ifYes
  25.     elseif bInput == false then
  26.         return ifNo
  27.     else
  28.         return "XXX"
  29.     end
  30. end
  31.  
  32. local function inst(bInput,ifNil)
  33.     if bInput then
  34.         return bInput
  35.     else
  36.         return ifNil
  37.     end
  38. end
  39.  
  40. local function fill(sInput,add)
  41.     local plus = ""
  42.     for i = 1,(10 - string.len(sInput)) do
  43.         plus = plus.." "
  44.     end
  45.     if add then
  46.         return sInput..plus..add
  47.     else
  48.         return sInput..plus
  49.     end
  50. end
  51.  
  52. local function getValues()
  53.     rctActive = fill(conv(reactor.getActive(),"YES","NO "))
  54.     rctRods = fill(reactor.getNumberOfControlRods())
  55.     rctEnergy = fill(reactor.getEnergyStored()," RF")
  56.     rctFuelTemp = fill(reactor.getFuelTemperature())
  57.     rctCaseTemp = fill(reactor.getCasingTemperature())
  58.     rctFuelAm = fill(reactor.getFuelAmount())
  59.     rctWasteAm = fill(reactor.getWasteAmount())
  60.     rctMaxFuel = fill(reactor.getFuelAmountMax())
  61.     rctEnergyProd = fill(reactor.getEnergyProducedLastTick(),UNIT)
  62.     rctCoType = fill(inst(reactor.getCoolantType(),"NONE"))
  63.     rctCoAm = fill(reactor.getCoolantAmount())
  64.     rctHotType = fill(inst(reactor.getHotFluidType(),"NONE"))
  65.     rctHotAm = fill(reactor.getHotFluidAmount())
  66.     rctReactiv = fill(reactor.getFuelReactivity())
  67.     rctFuelConsume = fill("ca. "..math.floor(reactor.getFuelConsumedLastTick()))
  68.     rctActiveCo = fill(conv(reactor.isActivelyCooled(),"ACTIVE","PASSIVE"))
  69. end
  70.  
  71. local function updateScreen()
  72.     term.setCursorPos(1,1)
  73.    
  74.     getValues()
  75.     print("ReactorOS\n")
  76.     print("Reactor active  : "..rctActive)
  77.     print("Reactor cooling : "..rctActiveCo)
  78.     print("Control rods    : "..rctRods)
  79.    
  80.     print("\nEnergy stored   : "..rctEnergy)
  81.     print("Production      : "..rctEnergyProd)
  82.    
  83.     print("Fuel temp       : "..rctFuelTemp.." C")
  84.     print("Case temp       : "..rctCaseTemp.." C")
  85.    
  86.     print("\nMax. Fuel       : "..rctMaxFuel.." mB")
  87.     print("Fuel left       : "..rctFuelAm.." mB")
  88.     print("Waste left      : "..rctWasteAm.." mB")
  89.     print("Fuel reactivity : "..rctReactiv.." %")
  90.     print("Fuel consumption: "..rctFuelConsume.." mB/t")
  91.    
  92.     print("\nCoolant type    : "..rctCoType)
  93.     print("Coolant amount  : "..rctCoAm.." mB")
  94.  
  95.     print("\nHot fluid type  : "..rctHotType)
  96.     print("Hot fluid amount: "..rctHotAm.." mB")
  97.    
  98.     term.setCursorPos(1,h)
  99. end
  100.  
  101. local function deb(sInput)
  102.     term.redirect(oldTerm)
  103.     print(sInput)
  104.     term.redirect(mon)
  105. end
  106.  
  107. local function list(tInput)
  108.     for i = 1,#tInput do
  109.         deb(tInput[i])
  110.     end
  111. end
  112.  
  113.  
  114. ---------------------------------------------------------------------------------------------------
  115. --Exec
  116.  
  117. if not name =="Controller" then
  118.     shell.run("label set Controller")
  119. else
  120. end
  121.  
  122. term.clear()
  123. term.setCursorPos(1,1)
  124.  
  125. print("ReactorOS")
  126.  
  127. wrap()
  128. oldTerm = term.redirect(mon)
  129. term.clear()
  130.  
  131. deb("Entering loop...")
  132.  
  133. term.setCursorPos(1,1)
  134. term.write("ReactorOS")
  135. sleep(1)
  136. term.clear()
  137.  
  138. while true do
  139.     updateScreen()
  140.     if rs.getInput(VIOLIN) ==true then
  141.         updateScreen()
  142.         term.setCursorPos(1,mh)
  143.         term.write("> Shutting down...")
  144.         sleep(1)
  145.         term.clear()
  146.         term.setCursorPos(mw / 2 - 4,mh / 2)
  147.         term.write("[INACTIVE]")
  148.         term.setCursorPos(mw / 2 - 10,mh)
  149.         term.write("OS made by TheSurgeon")
  150.         term.redirect(oldTerm)
  151.         term.write("Shutting down...")
  152.         os.shutdown()
  153.     end
  154.     sleep(0)
  155. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement