Advertisement
Guest User

Untitled

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