Advertisement
JaMaNi133

reactorSimple

Nov 26th, 2022 (edited)
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. reactor = peripheral.wrap("BigReactors-Reactor_0")
  2. monitor = peripheral.wrap("left")
  3.  
  4.  
  5. local P,I = 2.50 , 1
  6.  
  7.  
  8.  
  9.  
  10. local mathPower = 0  --   -1 to 1  
  11.  
  12. local mathInput = 0  --   -1 to 1
  13. local ipower = 0
  14. local iterm = 0
  15.  
  16. while true do
  17.     mathInput = (reactor.getEnergyStored()/10000000)*2 -1
  18.  
  19.     local ppower = -mathInput * P
  20.  
  21.     local iterm = -mathInput * I
  22.    
  23.     ipower = (ipower*0.98) + iterm
  24.  
  25.     mathPower = ppower + ipower
  26.  
  27.     if mathPower >= 1 then
  28.         mathPower = 1
  29.     end
  30.     if mathPower <= 0 then
  31.         mathPower = 0
  32.     end
  33.  
  34.     print("\n\n\nP: ",ppower)
  35.     print("I: ",ipower)
  36.     print("total power : ", mathPower*100,"%")
  37.     print("pi in: ", mathInput)
  38.     print("-------------------------")
  39.  
  40.    
  41.     reactor.setAllControlRodLevels(100-(100*mathPower))
  42.     sleep(.1)
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement