Advertisement
RLPGhost

Control Réactor v4

Apr 6th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.82 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.write("Quantite: "..fluidAmount.." mB"))
  67. md.setCursorPos(1,4)
  68. md.write("Remplissage: "..percentDrum.." %"))
  69.  
  70. -- tritium
  71.  
  72. local fluidRaw, fluidName, fluidAmount, fluidCapacity = getTank(t)
  73. percentDrum = math.floor(100 * fluidAmount / fluidCapacity )
  74. term.setCursorPos(1,2)
  75. term.write(fluidRaw.." "..tostring(fluidAmount).." mB  | Remplissage: "..tostring(percentDrum).." %" )
  76.  
  77. if percentDrum < 30 then
  78.     tritiumOn = 4
  79.     tritiumOff = 0
  80. else
  81.     tritiumOn = 0
  82.     tritiumOff = 2
  83. end
  84.  
  85. -- nitrogen
  86.  
  87. local fluidRaw, fluidName, fluidAmount, fluidCapacity = getTank(n)
  88. percentDrum = math.floor(100 * fluidAmount / fluidCapacity )
  89. term.setCursorPos(1,3)
  90. term.write(fluidRaw.." "..tostring(fluidAmount).." mB  | Remplissage: "..tostring(percentDrum).." %" )
  91.  
  92. if percentDrum < 30 then
  93.     nitrogen = 8
  94. else
  95.     nitrogen = 0
  96. end
  97.  
  98. -- lubrican
  99.  
  100. local fluidRaw, fluidName, fluidAmount, fluidCapacity = getTank(l)
  101. percentDrum = math.floor(100 * fluidAmount / fluidCapacity )
  102. term.setCursorPos(1,4)
  103. term.write(fluidRaw.." "..tostring(fluidAmount).." mB  | Remplissage: "..tostring(percentDrum).." %" )
  104.  
  105. if percentDrum < 30 then
  106.     lubrican = 16
  107. else
  108.     lubrican = 0
  109. end
  110.  
  111. -- redstone Output
  112.  
  113. local value = deutrium+tritiumOn+tritiumOff+nitrogen+lubrican
  114. term.setCursorPos(1,5)
  115. term.write("RedstoneOutput: "..tostring(value))
  116. redstone.setBundledOutput("top",value)
  117.  
  118. sleep(1)
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement