SHARE
TWEET

Untitled

a guest Jul 16th, 2019 63 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.  
  25.     redstone.setAnalogOutput("left", state and 1 or 0)
  26. end
  27. setInductor(false)
  28.  
  29. function setActive(state)
  30.     active = state
  31.  
  32.     local amt = 2000
  33.     if not state then amt = 0 end
  34.  
  35.     turbine.setFluidFlowRateMax(amt)
  36.  
  37.     redstone.setAnalogOutput("right", state and 1 or 0)
  38. end
  39. setActive(false)
  40.  
  41. while true do
  42.     speed = turbine.getRotorSpeed(speed)
  43.  
  44.         -- Prevent overspeed
  45.         if speed < target_speed then
  46.             setActive(true)
  47.         else if speed > max_speed then
  48.             setActive(false)
  49.         end
  50.  
  51.         -- Detach inductors when underspeed
  52.         if speed < target_speed - speed_band then
  53.             setInductor(false)
  54.         else if speed > target_speed + speed_band then
  55.             setInductor(true)
  56.         end
  57.     end
  58.  
  59.     -- send status update
  60.     if turbine_controller_id then
  61.         rednet.send(turbine_controller_id, {
  62.             id = turbine_index,
  63.             active = active,
  64.             engaged = engaged,
  65.             speed = speed,
  66.             target_speed = target_speed,
  67.             max_speed = max_speed,
  68.             energy = turbine.getEnergyProducedLastTick()
  69.         }, "turbine_control");
  70.     end
  71. end
  72.  
  73.     os.sleep(1)
  74. 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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top