Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. --Connexion redNet
  2.  
  3.  
  4. function draw_line(x, y, length, color)
  5. monitor.setBackgroundColor(color)
  6. monitor.setCursorPos(x,y)
  7. monitor.write(string.rep(" ", length))
  8. end
  9.  
  10. function draw_text(x, y, text, text_color, bg_color)
  11. monitor.setBackgroundColor(bg_color)
  12. monitor.setTextColor(text_color)
  13. monitor.setCursorPos(x,y)
  14. monitor.write(text)
  15.  
  16. end
  17.  
  18. function updateText()
  19. if id == 10 then
  20.  
  21. if msg == 0 then
  22. monitor.clear()
  23. cadragetop(colors.red)
  24. draw_text(5, 4, "Réacteur 1", colors.red, colors.black)
  25. draw_text(5, 17, "Réacteur 2", colors.red, colors.black)
  26. draw_text(8,8,"RF/T",colors.red,colors.black)
  27. draw_text(8,22,"RF/T", colors.red, colors.black)
  28. draw_text(7,7,tostring(msg), colors.red, colors.black)
  29. else
  30. cadragetop(colors.lime)
  31. affichage()
  32. draw_text(7,7,tostring(msg), colors.red, colors.black)
  33.  
  34. end
  35. elseif id == 17 then
  36.  
  37. if msg == 0 then
  38. monitor.clear()
  39. cadragebot(colors.red)
  40. draw_text(5, 4, "Réacteur 1", colors.red, colors.black)
  41. draw_text(5, 17, "Réacteur 2", colors.red, colors.black)
  42. draw_text(8,8,"RF/T",colors.red,colors.black)
  43. draw_text(8,22,"RF/T", colors.red, colors.black)
  44. draw_text(7,21,"0", colors.red, colors.black)
  45. else
  46. cadragebot(colors.lime)
  47. affichage()
  48. draw_text(7,21,tostring(msg), colors.red, colors.black)
  49. end
  50. else return
  51. end
  52. end
  53.  
  54. function connexion()
  55. rednet.open("top")
  56. id,msg = rednet.receive()
  57. updateText()
  58. end
  59.  
  60. -- Définit l'écran
  61. monitor = peripheral.wrap("bottom")
  62. monitor.setTextScale(1)
  63.  
  64. monitor.clear()
  65.  
  66. function cadragetop(color)
  67. draw_line(1, 1 ,18 , color)
  68. for i = 2,13 do
  69. draw_line(1,i,1 ,color)
  70. end
  71. for i = 2,13 do
  72. draw_line(18,i,1,color)
  73. end
  74. draw_line(1,13,18,color)
  75.  
  76. end
  77. function cadragebot(color)
  78. draw_line(1,14,18,color)
  79. for i = 15,25 do
  80. draw_line(1,i,1,color)
  81. end
  82. for i = 15,25 do
  83. draw_line(18,i,1,color)
  84. end
  85. draw_line(1,26,18,color)
  86. end
  87.  
  88.  
  89. draw_text(5, 4, "Réacteur 1", colors.red, colors.black)
  90. draw_text(5, 17, "Réacteur 2", colors.red, colors.black)
  91. draw_text(8,8,"RF/T",colors.red,colors.black)
  92. draw_text(8,22,"RF/T", colors.red, colors.black)
  93.  
  94.  
  95. while true do
  96. parallel.waitForAny(connexion)
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement