Advertisement
9903286

Untitled

Oct 22nd, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. t = peripheral.wrap("back")
  2. g = peripheral.wrap("left")
  3.  
  4. maxEnergy = 1000000
  5. rpm = t.getRotorSpeed()
  6. offsetX = 0
  7. offsetY = 0
  8.  
  9. if rpm > 1700 then
  10. speedUp = false
  11. else
  12. speedUp = true
  13. end
  14.  
  15. function getScaled(scaled, current, max)
  16. return (current * scaled / max)
  17. end
  18.  
  19. function updateCoil()
  20. rpm = t.getRotorSpeed()
  21. if speedUp == false then
  22. if rpm < 1800 then
  23. speedUp = true
  24. end
  25. else
  26. t.setInductorEngaged(false)
  27. if rpm > 1850 then
  28. speedUp = false
  29. t.setInductorEngaged(true)
  30. end
  31. end
  32. end
  33.  
  34. function updateTurbine()
  35. energy = t.getEnergyStored()
  36. if energy < maxEnergy then
  37. t.setActive(true)
  38. else
  39. t.setActive(false)
  40. end
  41. end
  42.  
  43. function isEmpty(s)
  44. return s == nil or s == ''
  45. end
  46.  
  47. while true do
  48. updateCoil()
  49. updateTurbine()
  50.  
  51. if t.getActive() then
  52. g.addText(5+offsetX,10+offsetY,"Active: TRUE")
  53. else
  54. g.addText(5+offsetX,10+offsetY,"Active: FALSE")
  55. end
  56.  
  57. g.addText(5+offsetX,40+offsetY,"RPM: "..t.getRotorSpeed())
  58.  
  59. g.addBox(4+offsetX,20+offsetY,100,15,0x000000,0.5)
  60. g.addGradientBox(6+offsetX,22+offsetY,getScaled(96,t.getEnergyStored(),maxEnergy),11,0x00FF00,1,0xFF0000,1,2)
  61.  
  62. -- g.addBox(4+offsetX,58+offsetY,29,39,0x000000,0.5)
  63. --
  64. -- if not isEmpty(t.getInputType()) then
  65. -- g.addLiquid(6+offsetX,60+offsetY,11,getScaled(35,t.getInputAmount(),t.getFluidAmountMax()),t.getInputType())
  66. -- end
  67. -- if not isEmpty(t.getOutputType()) then
  68. -- g.addLiquid(20+offsetX,60+offsetY,11,getScaled(35,t.getOutputAmount(),t.getFluidAmountMax()),t.getOutputType())
  69. -- end
  70.  
  71. sleep(0.25)
  72. g.clear()
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement