Advertisement
Guest User

turbine

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