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 1.44 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 cadragetop(color)
  19. draw_line(1, 1 ,18 , color)
  20. for i = 2,13 do
  21. draw_line(1,i,1 ,color)
  22. end
  23. for i = 2,13 do
  24. draw_line(18,i,1,color)
  25. end
  26. draw_line(1,13,18,color)
  27. end
  28.  
  29. function updateText()
  30. if id == 10 then
  31.  
  32. if msg == 0 then
  33. monitor.clear()
  34. cadragetop(colors.red)
  35. draw_text(5, 4, "Réacteur 1", colors.red, colors.black)
  36. draw_text(8,8,"RF/T",colors.red,colors.black)
  37. draw_text(7,7,"0", colors.red, colors.black)
  38. else
  39. cadragetop(colors.lime)
  40. draw_text(7,7,tostring(msg), colors.red, colors.black)
  41. end
  42. else return
  43. end
  44. end
  45.  
  46. function connexion()
  47. rednet.open("top")
  48. id,msg = rednet.receive()
  49. updateText()
  50. end
  51.  
  52. -- Définit l'écran
  53. monitor = peripheral.wrap("bottom")
  54.  
  55. monitor.setTextScale(1)
  56. monitor.clear()
  57.  
  58. draw_text(5, 4, "Réacteur 1", colors.red, colors.black)
  59. draw_text(8,8,"RF/T",colors.red,colors.black)
  60.  
  61.  
  62. while true do
  63. parallel.waitForAny(connexion)
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement