Advertisement
RLPGhost

Control Fluid

May 11th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.41 KB | None | 0 0
  1. local d = peripheral.wrap("drum_1")
  2. local t = peripheral.wrap("drum_2")
  3. local n = peripheral.wrap("drum_3")
  4. local l = peripheral.wrap("drum_4")
  5. local md = peripheral.wrap("monitor_0")
  6. local mt = peripheral.wrap("monitor_1")
  7. local mn = peripheral.wrap("monitor_2")
  8. local ml = peripheral.wrap("monitor_3")
  9.  
  10. local deutrium
  11. local tritiumOn
  12. local tritiumOff
  13. local nitrogen
  14. local lubrican
  15.  
  16. local amount
  17.  
  18. function getTank(tankPeriph)
  19.   local tableInfo = tankPeriph.getTankInfo()
  20.  
  21.   fluidRaw = nil
  22.   fluidName = nil
  23.   fluidAmount = nil
  24.   fluidCapacity = nil
  25.  
  26.   for k,v in pairs(tableInfo) do
  27.     fluidCapacity = v.capacity
  28.  
  29.     if v.contents then
  30.       for i,w in pairs(v.contents) do
  31.         if i == "rawName" then
  32.           fluidRaw = w
  33.         elseif i == "amount" then
  34.           fluidAmount = w
  35.         elseif i == "name" then
  36.           fluidName = w
  37.         end
  38.       end
  39.     end
  40.   end
  41.   return fluidRaw, fluidName, fluidAmount, fluidCapacity
  42. end
  43.  
  44. while true do
  45.  
  46. term.clear()
  47.  
  48. -- deutrium
  49.  
  50. local fluidRaw, fluidName, fluidAmount, fluidCapacity = getTank(d)
  51. percentDrum = math.floor(100 * fluidAmount / fluidCapacity )
  52. term.setCursorPos(1,1)
  53. term.write(fluidRaw.." "..tostring(fluidAmount).." mB  | Remplissage: "..tostring(percentDrum).." %" )
  54.  
  55. if percentDrum < 30 then
  56.     deutrium = 1
  57. else
  58.     deutrium = 0
  59. end
  60.  
  61. md.clear()
  62. md.setCursorPos(6,1)
  63. md.setTextColor(colors.lightBlue)
  64. md.write(fluidRaw)
  65. md.setCursorPos(1,3)
  66. md.setTextColor(colors.white)
  67. md.write("Quantite: ")
  68. md.setCursorPos(8,4)
  69. md.setTextColor(colors.yellow)
  70. md.write(tostring(fluidAmount))
  71. md.setTextColor(colors.white)
  72. md.write(" mB")
  73. md.setCursorPos(1,5)
  74. md.write("Remplissage: ")
  75. md.setTextColor(colors.yellow)
  76. md.write(tostring(percentDrum))
  77. md.setTextColor(colors.white)
  78. md.write(" %")
  79.  
  80. -- tritium
  81.  
  82. local fluidRaw, fluidName, fluidAmount, fluidCapacity = getTank(t)
  83. percentDrum = math.floor(100 * fluidAmount / fluidCapacity )
  84. term.setCursorPos(1,2)
  85. term.write(fluidRaw.." "..tostring(fluidAmount).." mB  | Remplissage: "..tostring(percentDrum).." %" )
  86.  
  87. if percentDrum < 30 then
  88.     tritiumOn = 4
  89.     tritiumOff = 0
  90. else
  91.     tritiumOn = 0
  92.     tritiumOff = 2
  93. end
  94.  
  95. mt.clear()
  96. mt.setCursorPos(6,1)
  97. mt.setTextColor(colors.lightBlue)
  98. mt.write(fluidRaw)
  99. mt.setCursorPos(1,3)
  100. mt.setTextColor(colors.white)
  101. mt.write("Quantite: ")
  102. mt.setCursorPos(8,4)
  103. mt.setTextColor(colors.yellow)
  104. mt.write(tostring(fluidAmount))
  105. mt.setTextColor(colors.white)
  106. mt.write(" mB")
  107. mt.setCursorPos(1,5)
  108. mt.write("Remplissage: ")
  109. mt.setTextColor(colors.yellow)
  110. mt.write(tostring(percentDrum))
  111. mt.setTextColor(colors.white)
  112. mt.write(" %")
  113.  
  114. -- nitrogen
  115.  
  116. local fluidRaw, fluidName, fluidAmount, fluidCapacity = getTank(n)
  117. percentDrum = math.floor(100 * fluidAmount / fluidCapacity )
  118. term.setCursorPos(1,3)
  119. term.write(fluidRaw.." "..tostring(fluidAmount).." mB  | Remplissage: "..tostring(percentDrum).." %" )
  120.  
  121. if percentDrum < 30 then
  122.     nitrogen = 8
  123. else
  124.     nitrogen = 0
  125. end
  126.  
  127. mn.clear()
  128. mn.setCursorPos(6,1)
  129. mn.setTextColor(colors.lightBlue)
  130. mn.write(fluidRaw)
  131. mn.setCursorPos(1,3)
  132. mn.setTextColor(colors.white)
  133. mn.write("Quantite: ")
  134. mn.setCursorPos(8,4)
  135. mn.setTextColor(colors.yellow)
  136. mn.write(tostring(fluidAmount))
  137. mn.setTextColor(colors.white)
  138. mn.write(" mB")
  139. mn.setCursorPos(1,5)
  140. mn.write("Remplissage: ")
  141. mn.setTextColor(colors.yellow)
  142. mn.write(tostring(percentDrum))
  143. mn.setTextColor(colors.white)
  144. mn.write(" %")
  145.  
  146. -- lubrican
  147.  
  148. local fluidRaw, fluidName, fluidAmount, fluidCapacity = getTank(l)
  149. percentDrum = math.floor(100 * fluidAmount / fluidCapacity )
  150. term.setCursorPos(1,4)
  151. term.write(fluidRaw.." "..tostring(fluidAmount).." mB  | Remplissage: "..tostring(percentDrum).." %" )
  152.  
  153. if percentDrum < 30 then
  154.     lubrican = 16
  155. else
  156.     lubrican = 0
  157. end
  158.  
  159. ml.clear()
  160. ml.setCursorPos(6,1)
  161. ml.setTextColor(colors.lightBlue)
  162. ml.write(fluidRaw)
  163. ml.setCursorPos(1,3)
  164. ml.setTextColor(colors.white)
  165. ml.write("Quantite: ")
  166. ml.setCursorPos(8,4)
  167. ml.setTextColor(colors.yellow)
  168. ml.write(tostring(fluidAmount))
  169. ml.setTextColor(colors.white)
  170. ml.write(" mB")
  171. ml.setCursorPos(1,5)
  172. ml.write("Remplissage: ")
  173. ml.setTextColor(colors.yellow)
  174. ml.write(tostring(percentDrum))
  175. ml.setTextColor(colors.white)
  176. ml.write(" %")
  177.  
  178. -- redstone Output
  179.  
  180. local value = deutrium+tritiumOn+tritiumOff+nitrogen+lubrican
  181. term.setCursorPos(1,5)
  182. term.write("RedstoneOutput: "..tostring(value))
  183. redstone.setBundledOutput("top",value)
  184.  
  185. sleep(1)
  186. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement