mcfeuersturm

2tcn

Jun 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local m = peripheral.find("monitor")
  2. local t = peripheral.wrap("rcirontankvalvetile_3")
  3. local t2 = peripheral.wrap("back")
  4. local warning = 90
  5. local cap
  6. local liquidColors = {{"Water", colors.blue },
  7. {"Steam", colors.lightGray},
  8. {"Lava", colors.orange},
  9. {"Fruit Juice", colors.green},
  10. {"uumatter", colors.purple, "UUMater"}}
  11.  
  12. function getTank(tankPeriph)
  13. local tableInfo = t.getTankInfo("unknown")
  14. local tableInfo2 = t2.getTankInfo("unknown")
  15.  
  16. fluidRaw = tableInfo.rawName
  17. fluidName = tableInfo.name
  18. fluidAmount = tableInfo.amount
  19. fluidCapacity = tableInfo[1].capacity
  20. contents = tableInfo[1].contents
  21.  
  22. fluidRaw2 = tableInfo2.rawName
  23. fluidName2 = tableInfo2.name
  24. fluidAmount2 = tableInfo2.amount
  25. fluidCapacity2 = tableInfo2[1].capacity
  26. contents2 = tableInfo2[1].contents
  27.  
  28. if contents then
  29. fluidRaw = contents.rawName
  30. fluidAmount = contents.amount
  31. fluidName = contents.name
  32. fluidRaw2 = contents2.rawName
  33. fluidAmount2 = contents2.amount
  34. fluidName2 = contents2.name
  35. end
  36.  
  37. return fluidRaw, fluidName, fluidAmount, fluidCapacity, fluidRaw2, fluidName2, fluidAmount2, fluidCapacity2
  38.  
  39. end
  40.  
  41. while true do
  42.   m.clear()
  43.   m.setCursorPos(1,1)
  44.  
  45.   local fluidRaw, fluidName, fluidAmount, fluidCapacity, fluidRaw2, fluidName2, fluidAmount2, fluidCapacity2 = getTank(tank)
  46.  
  47. if fluidName then
  48. cap = fluidCapacity / 1000
  49. amount = fluidAmount
  50. cap2 = fluidCapacity2 / 1000
  51. amount2 = fluidAmount2
  52.  
  53. if amount == nil then
  54. amount = 0
  55. percentfull = 0
  56. amount2 = 0
  57. percentfull2 = 0
  58. else
  59. amount = math.floor(amount / 1000)
  60. percentfull = math.floor(100 * amount / cap)
  61. amount2 = math.floor(amount2 / 1000)
  62. percentfull2 = math.floor(100 * amount2 / cap)
  63. end
  64. if fluidRaw == "Lava" then
  65. m.write("1. Tank ")
  66. m.setTextColor(colors.red)
  67. m.write(fluidRaw)
  68. m.setTextColor(colors.white)
  69. elseif fluidRaw == "Water" then
  70. m.write("1. Tank ")
  71. m.setTextColor(colors.blue)
  72. m.write(fluidRaw)
  73. m.setTextColor(colors.white)
  74. elseif fluidRaw == "uumatter" then
  75. m.write("1. Tank ")
  76. m.setTextColor(colors.purple)
  77. m.write("UUMatter")
  78. m.setTextColor(colors.white)
  79. end
  80. m.setCursorPos(1,2)
  81. m.write("Inhalt Eimer: ".. amount.."/"..cap.." Eimer")
  82. m.setCursorPos(1,3)
  83. m.write("Inhalt %: "..percentfull.."% ")
  84. m.setCursorPos(1,5)
  85. if fluidRaw2 == "Lava" then
  86. m.write("2. Tank ")
  87. m.setTextColor(colors.red)
  88. m.write(fluidRaw2)
  89. m.setTextColor(colors.white)
  90. elseif fluidRaw2 == "Water" then
  91. m.write("2. Tank ")
  92. m.setTextColor(colors.blue)
  93. m.write(fluidRaw2)
  94. m.setTextColor(colors.white)
  95. elseif fluidRaw == "uumatter" then
  96. m.write("2. Tank ")
  97. m.setTextColor(colors.purple)
  98. m.write("UUMatter")
  99. m.setTextColor(colors.white)
  100. end
  101. m.setCursorPos(1,6)
  102. m.write("Inhalt Eimer: "..amount2.."/"..cap2.." Eimer")
  103. m.setCursorPos(1,7)
  104. m.write("Inhalt %: "..percentfull2.."% ")
  105. m.setCursorPos(1,10)
  106. m.write("Gesamt:")
  107. local amountges = amount + amount2
  108. local capges = cap + cap2
  109. m.setCursorPos(1,11)
  110. m.write("Inhalt Eimer: "..amountges.."/"..capges.." Eimer")
  111. local percentfullmid = percentfull + percentfull2
  112. local percentfullges = percentfullmid / 2
  113. m.setCursorPos(1,12)
  114. m.write("Inhalt %: "..percentfullges.."%")
  115.  
  116.  
  117. if percentfull == lastpercent then
  118. print("Der 1. Tank ist zu "..percentfull.."% voll")
  119. elseif percentfull < 10 then
  120. sendpercent = " "..percentfull
  121. print("Der 2. Tank ist zu "..percentfull2.."% voll")
  122. elseif percentfull2 < 10 then
  123. sendpercent2 = " "..percentfull2
  124. else
  125. sendpercent = 100
  126. sendpercent2 = 100
  127. end
  128.  
  129. sleep(2)
  130. end
  131. end
Add Comment
Please, Sign In to add comment