Advertisement
Guest User

turbine

a guest
May 29th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. local component = require("component")
  2. local keyboard = require("keyboard")
  3. local term = require("term")
  4. local comp = require("comp")
  5. local sides = require("sides")
  6. local rs = component.redstone
  7. local gpu = component.gpu
  8.  
  9. term.clear()
  10. print("Enter desired RPM for all turbines:")
  11. RPM = io.read()
  12.  
  13. term.clear()
  14. print("Turbine program running. Hold LEFT CTRL to exit")
  15.  
  16. local t = comp.getTurbines()
  17.  
  18. local w,h = gpu.maxResolution()
  19. gpu.setResolution(w/2, h/2)
  20.  
  21.  
  22. while true do
  23.  
  24.   local totalEnergyOutput = 0
  25.  
  26.   gpu.fill(1, 1, 160, 50, " ")
  27.   gpu.setForeground(0x00ff00)
  28.  
  29.   t = comp.getTurbines()
  30.  
  31.   comp.enableAllTurbines(t)
  32.  
  33.   local tableFlow = comp.turbinePID(RPM)
  34.  
  35.   local c = tableLength(t)
  36.  
  37.     for k,v in pairs(t) do
  38.  
  39.       comp.toTurbine(t, k).setFluidFlowRateMax(tableFlow[k])
  40.    
  41.       gpu.set(1, k, "Turbine "..k.." energy output: "..tostring(round(comp.toTurbine(t, k).getEnergyProducedLastTick(), 1)).." RF/t at "..tostring(round(comp.toTurbine(t, k).getRotorSpeed(), 0)).." RPM")
  42.  
  43.       totalEnergyOutput = totalEnergyOutput + comp.toTurbine(t, k).getEnergyProducedLastTick()
  44.  
  45.       rotorSpeed = comp.toTurbine(t, k).getRotorSpeed()
  46.  
  47.     end
  48.  
  49.   gpu.setForeground(0xff0000)
  50.   gpu.set(1, c+2, "Total energy output: "..tostring(round(totalEnergyOutput, 1)).." RF/t")
  51.  
  52.  rsOut = (rotorSpeed*15)/1800
  53.  
  54.  rs.setOutput(sides.east, rsOut)
  55.  
  56.   if keyboard.isControlDown() then comp.cleanUp() term.clear() gpu.setForeground(0xffffff) gpu.setResolution(w, h) os.exit() end
  57.  
  58.   os.sleep(0.5)
  59.  
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement