Advertisement
Guest User

ReaktorAnzeige

a guest
Jun 17th, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.63 KB | None | 0 0
  1. local m = peripheral.wrap("monitor_0")
  2. local r = peripheral.wrap("back")
  3. local epp
  4. local estored
  5. local eproz
  6. local heatcasing
  7. local heatcore
  8. local fuel
  9. local fproz
  10. local waste
  11. local wproz
  12. local ractive
  13. local rodlevelarray = {}
  14.  
  15. function check()
  16.     ractive = r.getActive()
  17.     estored = r.getEnergyStored()
  18.     epp = r.getEnergyProducedLastTick()
  19.     heatcasing = r.getCasingTemperature()
  20.     heatcore = r.getFuelTemperature()
  21.     fuel = r.getFuelAmount()
  22.     waste = r.getWasteAmount()
  23.  
  24. end
  25.  
  26. function RodAnpassung()
  27.   for i = 0,23 do
  28.     rodlevelarray[i] = r.getControlRodLevel(i)
  29.     --print(rodlevelarray[i])
  30.     if estored >= 9900000 and ractive == true then
  31.       r.setControlRodLevel(i, (rodlevelarray[i] + 2))
  32.       print(i.." "..(rodlevelarray[i] + 2))
  33.     elseif estored <= 8000000 and ractive == true then
  34.       r.setControlRodLevel(i, (rodlevelarray[i] - 2))
  35.       print(i.." "..(rodlevelarray[i] - 2))
  36.     end
  37.    
  38.   end
  39. end
  40.  
  41. function rechnen()
  42.     eproz = (estored / 10000000) * 100
  43.     eps = math.ceil(eproz * 0.5)
  44.     fproz = (fuel / 1152000) * 100
  45.     fps = math.ceil(fproz * 0.5)
  46.     wproz = (waste / 1152000) * 100
  47.     wps = math.ceil(wproz * 0.5)
  48. end
  49.    
  50. function display()
  51.     m.setTextScale(1)
  52.     m.setBackgroundColor(colors.black)
  53.     m.clear()
  54.     m.setCursorPos(23,2)
  55.     m.write("Reaktor Monitor")
  56.     m.setCursorPos(7,4)
  57.     m.write("Fuel Temperature: "..math.floor(heatcore + 0.5).."壟F½82壟F½B0C")
  58.     m.setCursorPos(43,4)
  59.     if ractive == true then
  60.         m.setTextColor(colors.green)
  61.         m.write("Aktiviert")
  62.     else
  63.         m.setTextColor(colors.red)
  64.         m.write("Deaktiviert")
  65.     end
  66.     m.setTextColor(colors.white)
  67.     m.setCursorPos(7,6)
  68.     m.write("Casing Temperature: "..math.floor(heatcasing + 0.5).."壟F½82壟F½B0C")
  69.     m.setCursorPos(43,6)
  70.     m.write("Producing: "..math.floor(epp + 0.5).."RF/T")
  71.     m.setCursorPos(7,10)
  72.     m.write("Energy Stored")
  73.     m.setCursorPos(52,12.5)
  74.     m.write(math.floor(estored + 0.5).."RF")
  75.     m.setCursorPos(7,19)
  76.     m.write("Fuel/Waste")
  77.     m.setCursorPos(52,15.5)
  78.     m.write(math.floor(eproz + 0.5).."%")
  79.     m.setCursorPos(52,21.5)
  80.     m.write(math.floor(fproz + 0,5).."%")
  81.     m.setCursorPos(52,24.5)
  82.     m.write(math.floor(wproz + 0,5).."%")
  83.    
  84.     box(0,11,50,16,colors.red)
  85.         box(0,11,eps,16,colors.green) --Gespeicherte Energie Graph
  86.     box(0,20,50,25,colors.red)
  87.         box(0,20,fps,22,colors.green) --Fuel
  88.         box(0,23,wps,25,colors.blue) --Waste
  89. end
  90.  
  91. function box(xa,ya,xe,ye,col)
  92.     m.setTextScale(1)
  93.     m.setBackgroundColor(col)
  94.     for y = ya, ye do
  95.         for x = xa, xe do
  96.             m.setCursorPos(x,y)
  97.             m.write(" ")
  98.         end
  99.     end
  100. end
  101.  
  102. --shell.run("bg ReaktorAnzeigeGraphen")
  103.  
  104. while true do
  105.     check()
  106.  RodAnpassung()
  107. --  rechnen()
  108. --  display()
  109.     sleep(1)
  110. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement