Guest User

Turbine v0.1

a guest
Dec 11th, 2019
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local turbine
  2. turbine = peripheral.find("BigReactors-Turbine")
  3. local mon
  4. mon = peripheral.wrap("back")
  5. rednet.open("bottom")
  6. rednet.host("hq")
  7.  
  8. TankTimeout = 1
  9.  
  10. local NumTanks = 7
  11. local Tanks = {"tk01", "tk02", "tk03", "tk04", "tkA1", "tkA2", "tkA3"}
  12. local Fluid = {"oil", "oil", "oil", "oil", "stm", "gas", "dsl"}
  13. local MxAmt = {6400, 6400, 6400, 6400, 6400, 6400, 6400}
  14. local CrStp = {0, 0, 0, 0, 0, 0, 0}
  15. local MxStp = {4, 4, 4, 4, 4, 4, 4}
  16.  
  17. local MxOil = 0
  18. local CrOil = 0
  19. local MxStm = 0
  20. local CrStm = 0
  21. local MxGas = 0
  22. local CrGas = 0
  23. local MxDsl = 0
  24. local CrDsl = 0
  25.  
  26. function UpdateTurbine()
  27. mon.setCursorPos(1,1)
  28. mon.write("RPM")
  29. speed = turbine.getRotorSpeed()
  30. speed = math.floor(speed)
  31. mon.setCursorPos(1,2)
  32. mon.write(tostring(speed))
  33.  
  34. mon.setCursorPos(1,4)
  35. mon.write("Steam Flow")
  36. flow = turbine.getFluidFlowRate()
  37. mon.setCursorPos(1,5)
  38. mon.write(tostring(flow) + " mb/t")
  39.  
  40. mon.setCursorPos(1,7)
  41. mon.write("Steam Flow")
  42. powerOut = turbine.getEnergyProducedLastTick()
  43. mon.setCursorPos(1,8)
  44. mon.write(tostring(math.floor(powerOut)) + " RF/t")
  45. end
  46.  
  47. function UpdateFluids()
  48. mon.setCursorPos(17,1)
  49. mon.write("Oil Stored")
  50. mon.setCursorPos(17,2)
  51. mon.write("~" + CrOil + " B")
  52. mon.setCursorPos(17,3)
  53. mon.write(tostring(CrOil / MxOil) + "%")
  54.  
  55. mon.setCursorPos(17,5)
  56. mon.write("Gasoline Stored")
  57. mon.setCursorPos(17,6)
  58. mon.write("~" + CrGas + " B")
  59. mon.setCursorPos(17,7)
  60. mon.write(tostring(CrGas / MxGas) + "%")
  61.  
  62. mon.setCursorPos(17,9)
  63. mon.write("Diesel Stored")
  64. mon.setCursorPos(17,10)
  65. mon.write("~" + CrDsl + " B")
  66. mon.setCursorPos(17,11)
  67. mon.write(tostring(CrDsl / MxDsl) + "%")
  68.  
  69. mon.setCursorPos(17,13)
  70. mon.write("Steam Stored")
  71. mon.setCursorPos(17,14)
  72. mon.write("~" + CrStm + " B")
  73. mon.setCursorPos(17,15)
  74. mon.write(tostring(CrStm / MxStm) + "%")
  75. end
  76.  
  77. for i = 1, NumTanks do
  78. if (Fluid[i] == "oil") then
  79. MxOil = MxOil + MxAmt[i]
  80. elseif (Fluid[i] == "stm") then
  81. MxStm = MxStm + MxAmt[i]
  82. elseif (Fluid[i] == "gas") then
  83. MxGas = MxGas + MxAmt[i]
  84. elseif (Fluid[i] == "dsl") then
  85. MxDsl = MxDsl + MxAmt[i]
  86. end
  87.  
  88. while (true) do
  89. CrOil = 0
  90. CrStm = 0
  91. CrGas = 0
  92. CrDsl = 0
  93.  
  94. for i = 1, NumTanks do
  95. rednet.broadcast(Tanks[i], "tanks")
  96. senderID, msg, protocol = rednet.receive("tanks", TankTimeout)
  97. CrStp[i] = tonumber(msg)
  98. if (Fluid[i] == "oil") then
  99. CrOil = CrOil + (CrStp[i] / MxStp[i] * MxAmt[i])
  100. elseif (Fluid[i] == "stm") then
  101. CrStm = CrStm + (CrStp[i] / MxStp[i] * MxAmt[i])
  102. elseif (Fluid[i] == "gas") then
  103. CrGas = CrGas + (CrStp[i] / MxStp[i] * MxAmt[i])
  104. elseif (Fluid[i] == "dsl") then
  105. CrDsl = CrDsl + (CrStp[i] / MxStp[i] * MxAmt[i])
  106. end
  107. end
  108.  
  109. mon.clear()
  110. UpdateTurbine()
  111. UpdateFluids()
  112. end
RAW Paste Data