Advertisement
Guest User

Untitled

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