Advertisement
Guest User

test

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