Darknio

Big Reactor

Nov 29th, 2014
514
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.61 KB | None | 0 0
  1.    
  2.  
  3.             BigReactor = "BigReactors-Reactor_1" --Reactor Slot
  4.             Monitor_Slot = "monitor_1"                       --Monitor Slot
  5.      
  6.         monitor = peripheral.wrap(Monitor_Slot)
  7.         monitor.clear()
  8.         monitor.setTextScale(1)
  9.         term.setBackgroundColor(2048)
  10.            
  11.      
  12.             local stored= 10000000 --Anzeige Max Interner Speicher
  13.            
  14.            
  15.         local reactor = peripheral.wrap(BigReactor)
  16.         local reactorTemp=reactor.getFuelTemperature()
  17.         local reactorCasingTemp=reactor.getCasingTemperature()
  18.         local reactorFuel=reactor.getFuelAmount()
  19.         local reactorRFTick = reactor.getEnergyProducedLastTick()
  20.         local reactorEnergy = reactor.getEnergyStored()
  21.         local backgoundColor = 32
  22.         local onoff = 1
  23.          
  24.             local PosX = 0
  25.             local PosY = 0
  26.             local AnAus = true
  27.             local autostart = "Aus"
  28.              
  29.             local zeileX = 24
  30.             local zeileY = 3
  31.              
  32.         function Clear()
  33.         term.clear()
  34.         term.setCursorPos(1,1)
  35.         end
  36.          
  37.              function Autostart()
  38.              if autostart == "An" then
  39.                     if (reactorEnergy < storedTwo) and (storedTwo<(stored/2))  then
  40.                             reactor.setActive(true)
  41.                     else
  42.                             reactor.setActive(false)
  43.                     end
  44.             end
  45.             end
  46.      
  47.         function Update()
  48.         local reactor = peripheral.wrap(BigReactor)
  49.         local reactorTemp=reactor.getFuelTemperature()
  50.         local reactorCasingTemp=reactor.getCasingTemperature()
  51.         local reactorFuel=reactor.getFuelAmount()
  52.         local reactorRFTick = reactor.getEnergyProducedLastTick()
  53.         local reactorEnergy = reactor.getEnergyStored()
  54.          
  55.         reactorTempNew=math.ceil(reactorTemp)
  56.         reactorCasingTempNew=math.ceil(reactorCasingTemp)
  57.         reactorFuelNew=math.ceil(reactorFuel)
  58.         reactorRFTickNew=math.ceil(reactorRFTick)
  59.         reactorEnergyNew=math.ceil(reactorEnergy)
  60.         eprozent = reactorEnergy/stored*100
  61.             eprozentNew =math.ceil(eprozent)
  62.             local zeileX = 24
  63.             local zeileY = 3
  64.            
  65.             OnOff()
  66.             end
  67.          
  68.     function OnOff()
  69.      
  70.     if reactorOnline == true then
  71.             AnAus = false
  72.             Status = "An"
  73.     elseif reactorOnline == false then
  74.             AnAus = true
  75.             Status = "Aus"
  76.              
  77.     end      
  78.     end
  79.      
  80.      
  81.      
  82.      
  83.         function Active()
  84.         write("Online: ")
  85.         reactorOnline = reactor.getActive()
  86.             term.setCursorPos(23,3)
  87.        
  88.             if reactorOnline == true then
  89.         backgoundColor = 32
  90.         term.setTextColor(32)
  91.         print(Status)
  92.         term.setTextColor(32768)
  93.         else
  94.         backgoundColor = 16384
  95.         term.setTextColor(16384)
  96.          
  97.         print(Status)
  98.          
  99.         term.setTextColor(32768)
  100.          
  101.         end
  102.         end
  103.      
  104.            
  105.        function Time()
  106.     write(textutils.formatTime(os.time(), true))
  107.      
  108.     end
  109.      
  110.      
  111.     function Header()
  112.     term.setBackgroundColor(colors.lightBlue)
  113.     monitor.setTextScale(1)
  114.     write("Reactor Monitor      ")
  115.     monitor.setTextScale(1)
  116.     term.setBackgroundColor(colors.red)
  117.     term.setTextColor(colors.white)
  118.     write(" ")
  119.     Time()
  120.     print("    ")
  121.     term.setBackgroundColor(colors.white)
  122.     term.setTextColor(colors.black)
  123.      
  124.     end
  125.      
  126.     function Screen()
  127.     term.setTextColor(colors.black)
  128.     term.setBackgroundColor(colors.lightGray)
  129.     print("Autostart                          ")
  130.     term.setCursorPos(23,2)
  131.     print(autostart)
  132.     term.setBackgroundColor(colors.white)
  133.     Active()
  134.     term.setBackgroundColor(colors.lightGray)
  135.     write("Temp:                              ")
  136.     term.setCursorPos(23,4)
  137.     print(reactorTempNew)
  138.     term.setBackgroundColor(colors.white)
  139.     write("Casing:                       ")
  140.     term.setCursorPos(23,5)
  141.     print(reactorCasingTempNew)
  142.     term.setBackgroundColor(colors.lightGray)
  143.     write("Fuel:                             ")
  144.     term.setCursorPos(23,6)
  145.     print(reactorFuelNew)
  146.     term.setBackgroundColor(colors.white)
  147.     write("RF/Tick:                             ")
  148.     term.setCursorPos(23,7)
  149.     print(reactorRFTickNew)
  150.     term.setBackgroundColor(colors.lightGray)
  151.     write("Energie:                              ")          
  152.     term.setCursorPos(23,8)
  153.     print (eprozentNew .."/100%")
  154.      
  155.      
  156.      
  157.      
  158.     term.setBackgroundColor(colors.white)
  159.     end
  160.      
  161.     function Run()
  162.     Clear()
  163.     Update()
  164.     Header()
  165.     Screen()
  166.     Autostart()
  167.     --print("x " .. PosX)
  168.     --print("y " .. PosY)
  169.      
  170.      
  171.      
  172.      
  173.     sleep(0.5)
  174.     end
  175.      
  176.      
  177.      
  178.     function Touch()
  179.      
  180.             event,side,PosX,PosY = os.pullEvent("monitor_touch")
  181.                     if PosY == 3 then
  182.                             reactor.setActive(AnAus)
  183.                     elseif PosY == 2 then
  184.      
  185.                             if autostart == "Aus" then
  186.                                      autostart = "An"
  187.                             elseif autostart == "An" then
  188.                                      autostart = "Aus"
  189.                             end
  190.                            
  191.      
  192.                             end
  193.      
  194.      
  195.                             end
  196.      
  197.      
  198.      
  199.      
  200.                    
  201.     while true do
  202.     parallel.waitForAny(Run,Touch)
  203.     end
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment