Advertisement
Guest User

Untitled

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