Advertisement
Uranium_49

Untitled

Jan 30th, 2025
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. local mon = peripheral.wrap("right")
  2.  
  3. rednet.open("left")
  4.  
  5. mon.setBackgroundColor(colors.black)
  6. mon.clear()
  7.  
  8. function boxe(x, y, xa, ya, mon, titre)
  9. mon.setTextScale(1)
  10. mon.setCursorPos(x, y)
  11. mon.setBackgroundColor(colors.gray)
  12. mon.write(" ")
  13. mon.setBackgroundColor(colors.black)
  14. mon.setTextColor(colors.yellow)
  15. mon.setCursorPos(x + 2, y)
  16. mon.write(" " .. titre .. " ")
  17. local xc, yc = mon.getCursorPos()
  18. for xc = xc, xa + x do
  19. mon.setCursorPos(xc, y)
  20. mon.setBackgroundColor(colors.gray)
  21. mon.write(" ")
  22. xc = xc + 1
  23. end
  24. local xc, yc = mon.getCursorPos()
  25. yc = y + 1
  26. for yc = y, ya + y do
  27. mon.setCursorPos(x, yc)
  28. mon.setBackgroundColor(colors.gray)
  29. mon.write(" ")
  30. mon.setCursorPos(x + xa, yc)
  31. mon.setBackgroundColor(colors.gray)
  32. mon.write(" ")
  33. yc = yc + 1
  34. end
  35. xb = x
  36. for xb = x, xa + x do
  37. mon.setCursorPos(xb, y + ya)
  38. mon.setBackgroundColor(colors.gray)
  39. mon.write(" ")
  40. xb = xb + 1
  41. end
  42. end
  43.  
  44. function reactorDrow(on)
  45. mon.setBackgroundColor(colors.lightGray)
  46. mon.setTextColor(colors.white)
  47. local g = 13
  48. for i = 29, g do
  49. mon.setCursorPos(25, i)
  50. mon.write(" ")
  51. end
  52. mon.setBackgroundColor(colors.black)
  53. local g = 15
  54. for i = 27, g do
  55. colorReactor(28,17,i,on)
  56. end
  57.  
  58. end
  59.  
  60. function colorReactor(x,xa,y,on)
  61. mon.setTextColor(colors.white)
  62. for i=0, xa-1 do
  63. color=math.random(1,4)
  64. if on == false then
  65. mon.setBackgroundColor(colors.black)
  66. elseif color == 1 then
  67. mon.setBackgroundColor(colors.red)
  68. elseif color == 2 then
  69. mon.setBackgroundColor(colors.lightBlue)
  70. elseif color == 3 then
  71. mon.setBackgroundColor(colors.lime)
  72. else
  73. mon.setBackgroundColor(colors.orange)
  74. end
  75. mon.setCursorPos(x+i,y)
  76. mon.write(" ")
  77. end
  78. end
  79.  
  80. function setScreenColor(mon, color)
  81. local colorsList = {
  82. white = colors.white,
  83. orange = colors.orange,
  84. magenta = colors.magenta,
  85. lightBlue = colors.lightBlue,
  86. yellow = colors.yellow,
  87. lime = colors.lime,
  88. pink = colors.pink,
  89. gray = colors.gray,
  90. lightGray = colors.lightGray,
  91. cyan = colors.cyan,
  92. purple = colors.purple,
  93. blue = colors.blue,
  94. brown = colors.brown,
  95. green = colors.green,
  96. red = colors.red,
  97. black = colors.black
  98. }
  99. if colorsList[color] then
  100. mon.setBackgroundColor(colorsList[color]) -- Change la couleur de fond
  101. else
  102. print("Couleur invalide !")
  103. end
  104. end
  105.  
  106.  
  107.  
  108. function drawGraph(mon, niveau, niveauMax, niveauMin, unitee, x, y, xa, ya, orientation, backgroundColors, fillColors)
  109.  
  110. local pointx = 0
  111. local pointy = 0
  112.  
  113. ya = ya -1
  114. xa = xa -1
  115.  
  116. pointy = ya * (niveauMax - niveau) / niveauMax
  117. pointx = xa * (niveauMax - niveau) / niveauMax
  118.  
  119. if orientation <= 2 then
  120. if orientation == 1 then
  121. y1 = y+ya-pointy
  122. y2 = y+ya
  123. y3 = y
  124. y4 = y+ya-pointy
  125. y5 = y+ya-pointy
  126. else
  127. y1 = y
  128. y2 = y+pointy
  129. y3 = y+pointy
  130. y4 = y+ya
  131. y5 = y+pointy
  132. end
  133.  
  134. for j = y1 , y2 do
  135. for i = x , xa+x do
  136. setScreenColor(mon, backgroundColors)
  137. mon.setCursorPos(i, j)
  138. mon.write(" ")
  139. end
  140. end
  141. for j = y3 , y4 do
  142. for i = x , xa+x do
  143. setScreenColor(mon, fillColors)
  144. mon.setCursorPos(i, j)
  145. mon.write(" ")
  146. end
  147. end
  148. mon.setCursorPos(x, y5)
  149. mon.write(niveauMax .. unitee)
  150.  
  151. elseif orientation >= 3 then
  152. if orientation == 3 then
  153. x1 = x+xa-pointx
  154. x2 = x+xa
  155. x3 = x
  156. x4 = x+xa-pointx
  157. x5 = x+xa-pointx
  158. else
  159. x1 = x
  160. x2 = x+pointx
  161. x3 = x+pointx
  162. x4 = x+xa
  163. x5 = x+pointx
  164. end
  165.  
  166. for i = x1 , x2 do
  167. for j = y , ya+y do
  168. setScreenColor(mon, backgroundColors)
  169. mon.setCursorPos(i, j)
  170. mon.write(" ")
  171. end
  172. end
  173. for i = x3 , x4 do
  174. for j = y , ya+y do
  175. setScreenColor(mon, fillColors)
  176. mon.setCursorPos(i, j)
  177. mon.write(" ")
  178. end
  179. end
  180. mon.setBackgroundColor(colors.black)
  181. mon.setCursorPos(x5, (y-1))
  182. mon.write(niveauMax .. unitee)
  183. end
  184. end
  185.  
  186. while true do
  187.  
  188. sender,message = rednet.receive("reactor")
  189.  
  190. reactorDrow(message.status)
  191. drawGraph(mon,message.coolant.amount/1000,32500,0,"B",6,12,7,19,1,"gray","blue")
  192. drawGraph(mon,message.fuel.amount,400000,0,"mb",15,12,7,19,1,"gray","brown")
  193. drawGraph(mon,message.heatCoolant.amount/1000,32500,0,"B",51,12,7,19,1,"gray","white")
  194. drawGraph(mon,message.waste.amount,400000,0,"mb",60,12,7,19,1,"gray","green")
  195. drawGraph(mon,math.floor(message.temp*10+0.5)/10-273.15,500,0,"Β°C",6,5,60,5,4,"gray","red")
  196. drawGraph(mon,math.floor(message.rate/100+0.5)/50,20,0,"mb/t",10,37,52,1,4,"gray","green")
  197.  
  198. mon.setBackgroundColor(colors.black)
  199. mon.setCursorPos(6,32)
  200. mon.write("Coolant")
  201. mon.setCursorPos(16,32)
  202. mon.write("Fuel")
  203. mon.setCursorPos(52,32)
  204. mon.write("Steam")
  205. mon.setCursorPos(61,32)
  206. mon.write("Waste")
  207. mon.setCursorPos(6,34)
  208. mon.write("Rate")
  209.  
  210. boxe(3, 2, 66, 37, mon, "Reacteur Γ  fission:")
  211.  
  212. --sleep(1)
  213. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement