Advertisement
MrLetsplay2003

CCReacV2

Jan 1st, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. enlim=8000000
  2. enmin=3000000
  3.  
  4. function getEnSt()
  5.  return re.getEnergyStored()--[[+enc.getEnergyStored()]]
  6. end
  7.  
  8. function printStat()
  9.  re=peripheral.wrap("BigReactors-Reactor_53")
  10.  --enc=peripheral.wrap("tile_blockcapacitorbank_name_27")
  11.  g=peripheral.wrap("right")
  12.  if(re.getActive())then
  13.   str = "An"
  14.  else
  15.   str = "Aus"
  16.  end
  17.  print("Terminal Reaktor:"..str)
  18.  print("Energie: "..re.getEnergyProducedLastTick().." RF/t")
  19.  print("Energie gespeichert: "..getEnSt().." RF")
  20.  --print("An: "..re.getActive())
  21.  print("Fuel: "..re.getFuelAmount().."/"..re.getFuelAmountMax())
  22. end
  23.  
  24. function round(val,decs)
  25.  local mult = 10^decs
  26.  return math.floor(val*mult)/mult
  27. end
  28.  
  29. function map(val,omax,nmax)
  30.  return val/omax*nmax
  31. end
  32.  
  33. function updGlasses()
  34.  g.clear()
  35.  if(re.getActive() and getEnSt()>enmin)then
  36.   col=0x00FF00
  37.  elseif(re.getActive() and getEnSt()<enmin) then
  38.   col=0xFF0000
  39.  else
  40.   col=0xFF8800
  41.  end
  42.  h = 12
  43.  g.addBox(1,h+1,100,10,0x000000,0.7)
  44.  enst = getEnSt()
  45.  enmax = 10000000--[[+enc.getMaxEnergyStored()]]
  46.  g.addBox(1,h+1,map(enst,enmax,100),10,col,0.7)
  47.  g.addBox(1+map(enmin,enmax,100),h+1,1,10,0x5555FF,0.7)
  48.  g.addBox(1+map(enlim,enmax,100),h+1,1,10,0x5555FF,0.7)
  49.  g.addText(1,h+14,round(enst/enmax*100,2).."%",0xFF5555)
  50.  g.sync()
  51. end
  52. function checkreac()
  53.  enst=getEnSt()
  54.  if enst>=enlim then
  55.   re.setActive(false)
  56.  elseif enst<=enmin then
  57.   re.setActive(true)
  58.  end
  59. end
  60.  
  61. while true do
  62.  printStat()
  63.  updGlasses()
  64.  sleep(1)
  65.  shell.run("clear")
  66.  checkreac()
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement