Bendix

reaktorControle

Dec 10th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. function detectDevice(DeviceName)
  2.   DeviceSide="nix"
  3.    for a,b in pairs(redstone.getSides()) do
  4.       if peripheral.getType(b)==DeviceName then
  5.          DeviceSide = b
  6.          break
  7.       end
  8.    end
  9.    return(DeviceSide)
  10. end
  11. --BigReactors-Reactor
  12. function clearline(line)
  13.     monitor.setCursorPos(1,line)
  14.     monitor.clearLine()
  15. end
  16.  
  17. function round(num)
  18.     vor, nach = math.modf(num)
  19.     if (nach >= 0.5) then
  20.         vor = vor +1
  21.     end
  22.     return vor
  23. end
  24.  
  25. reaktor = peripheral.wrap(detectDevice("BigReactors-Reactor"))
  26. monitor = peripheral.wrap(detectDevice("monitor"))
  27.  
  28. while (true) do
  29.    storedE = reaktor.getEnergyStored()
  30.    monitor.setCursorPos(1,1)
  31.    monitor.clearLine(1)
  32.    monitor.write("Interner Speicher bei ")
  33.    monitor.write(math.floor(reaktor.getEnergyStored()/100000))
  34.    monitor.write(" %")
  35. --  monitor.write(storedE/1000)
  36.     if (reaktor.getEnergyStored()>=9800000) then
  37.         reaktor.setActive(false)
  38.  
  39.       monitor.setCursorPos(1,2)
  40.       monitor.clearLine(2)
  41.       monitor.setBackgroundColor(colors.red)
  42.       monitor.setTextColor(colors.black)
  43.       monitor.write("Reaktor offline")
  44.       monitor.setBackgroundColor(colors.black)
  45.       monitor.setTextColor(colors.white)   
  46.    end
  47.     if (reaktor.getEnergyStored()<= 1000000) then
  48.         reaktor.setActive(true)
  49.      
  50.       monitor.setCursorPos(1,2)
  51.       monitor.clearLine(2)
  52.       monitor.setBackgroundColor(colors.green)
  53.       monitor.setTextColor(colors.black)
  54.       monitor.write("Reaktor online")
  55.       monitor.setBackgroundColor(colors.black)
  56.       monitor.setTextColor(colors.white)   
  57.     end
  58.  
  59.     sleep(1)
  60.    storedE2 = reaktor.getEnergyStored()
  61.    usedEnergy = storedE - storedE2
  62.    usedEnergy = usedEnergy /1000
  63.  
  64.     --monitor.clear(),monitor.setCursorPos(1,1)
  65.    monitor.setCursorPos(1,5)
  66.    monitor.clearLine(5)
  67. if (usedEnergy  >=0) then
  68.    monitor.write("aktueller Verbrauch bei: ")
  69. else
  70.    monitor.write("aktuelle Aufladung mit")
  71. end
  72.    monitor.setCursorPos(1,6)
  73.    monitor.clearLine(6)
  74.  
  75.    monitor.write(round(usedEnergy))
  76.    monitor.write(" kRF")
  77.     sleep(1)
  78.  
  79.     --monitor.clear()
  80.     --monitor.setCursorPos(1,1)
  81. end
Add Comment
Please, Sign In to add comment