SHARE
TWEET

Untitled

a guest Jul 16th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --https://github.com/erogenousbeef/BigReactors/blob/fdb050fb9cff0f7f8b79cabc08b157122832a90f/src/main/java/erogenousbeef/bigreactors/common/multiblock/tileentity/TileEntityTurbineComputerPort.java
  2.  
  3. max_speed = 2100
  4. target_speed = 1800
  5. speed_band = 50
  6.  
  7. turbine_index = os.getComputerLabel()
  8.  
  9. term.clear()
  10. term.setCursorPos(1,1)
  11.  
  12. turbine = peripheral.wrap("back")
  13.  
  14. rednet.open("top")
  15. turbine_controller_id = rednet.lookup("turbine_control", "turbine_control")
  16. print("Turbine controller at: " .. (turbine_controller_id or "nil"));
  17.  
  18. engaged = false
  19. active = false
  20.  
  21. function setInductor(state)
  22.     engaged = state
  23.     turbine.setInductorEngaged(state)
  24. end
  25. setInductor(false)
  26.  
  27. function setActive(state)
  28.     active = state
  29.  
  30.     local amt = 2000
  31.     if not state then amt = 0 end
  32.  
  33.     turbine.setFluidFlowRateMax(amt)
  34. end
  35. setActive(false)
  36.  
  37. while true do
  38.     speed = turbine.getRotorSpeed(speed)
  39.  
  40.         -- Prevent overspeed
  41.         if speed < target_speed then
  42.             setActive(true)
  43.         else if speed > max_speed then
  44.             setActive(false)
  45.         end
  46.  
  47.         -- Detach inductors when underspeed
  48.         if speed < target_speed - speed_band then
  49.             setInductor(false)
  50.         else if speed > target_speed + speed_band then
  51.             setInductor(true)
  52.         end
  53.     end
  54.  
  55.     -- send status update
  56.     if turbine_controller_id then
  57.         rednet.send(turbine_controller_id, {
  58.             id = turbine_index,
  59.             active = active,
  60.             engaged = engaged,
  61.             speed = speed,
  62.             target_speed = target_speed,
  63.             max_speed = max_speed,
  64.             energy = turbine.getEnergyProducedLastTick()
  65.         }, "turbine_control");
  66.     end
  67.  
  68.     os.sleep(1)
  69. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top