Advertisement
ZeProf2ModsYTB

FrenchFlag

Apr 4th, 2025 (edited)
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. -- Fonction pour afficher une image ASCII sur un moniteur
  2. local function displayImage(monitor, image)
  3. -- Efface le moniteur
  4. monitor.clear()
  5.  
  6. -- Récupère la taille du moniteur
  7. local width, height = monitor.getSize()
  8.  
  9. -- Parcourt chaque ligne de l'image
  10. for y, row in ipairs(image) do
  11. if y > height then break end -- Arrête si l'image dépasse la hauteur du moniteur
  12. -- Tronque ou remplit la ligne pour qu'elle corresponde à la largeur du moniteur
  13. local line = row:sub(1, width) -- Tronque si la ligne est trop longue
  14. if #line < width then
  15. line = line .. string.rep(" ", width - #line) -- Remplit avec des espaces si trop courte
  16. end
  17. monitor.setCursorPos(1, y)
  18. monitor.write(line)
  19. end
  20. end
  21.  
  22. -- ASCII art à afficher
  23. local image = {
  24. "####################################################################################################",
  25. "####################################################################################################",
  26. "####################################################################################################",
  27. "####################################################################################################",
  28. "######################################+=-:......:-=+################################################",
  29. "##################################=:. -@@- .:=############################################",
  30. "###############################+. :%@@@@%: .+#########################################",
  31. "#############################=. .#@@@@@@@#. .=#######################################",
  32. "###########################*. .*@@@@@@@%. .*#####################################",
  33. "##########################- .+@@@@@@@@: .-. -####################################",
  34. "#########################- -@@@@@@@@: -@@@= -###################################",
  35. "########################- :@@@@@@@@=. :@@@@@@@: -##################################",
  36. "#######################*. .+@@@@@@@%: :%@@@@@@@@@%: .*#################################",
  37. "#######################. .*@@@@@@@%..#@@@@@@@@@@@@@#. .#################################",
  38. "######################+ +*. .#@@@@@@@@@@@@@@%:%@@@@@@@+ +################################",
  39. "######################= =@@@@+. :%@@@@@@@@@@@: :@@@@@@@@= =################################",
  40. "######################=.%@@@@@@@= +@@@@@@@@+ =@@@@@@@%.=################################",
  41. "######################= =@@@@@@@@: :%@@@@@@@@@@%: .+@@@@= =################################",
  42. "######################+ *@@@@@@@%:#@@@@@@@@@@@@@@#. .** +################################",
  43. "#######################. .#@@@@@@@@@@@@@%..%@@@@@@@*. .#################################",
  44. "#######################*. .%@@@@@@@@@@: :@@@@@@@@+. .*#################################",
  45. "########################- -@@@@@@@- -@@@@@@@@- -##################################",
  46. "#########################- .=@@@=. :@@@@@@@@=. -###################################",
  47. "##########################- .-. :%@@@@@@@+. -####################################",
  48. "###########################*. .#@@@@@@@*. .*#####################################",
  49. "#############################=. .*@@@@@@@#: .=#######################################",
  50. "###############################+. :%@@@@%: .+#########################################",
  51. "##################################=:. -@@- .:=############################################",
  52. "######################################+-::......::-+################################################",
  53. "####################################################################################################",
  54. "####################################################################################################",
  55. "####################################################################################################",
  56. "####################################################################################################",
  57. }
  58.  
  59. -- Programme principal
  60. local function main()
  61. -- Trouve un moniteur connecté
  62. local monitor = peripheral.find("monitor")
  63. if not monitor then
  64. print("Erreur : Aucun moniteur trouvé.")
  65. return
  66. end
  67.  
  68. -- Affiche l'image ASCII sur le moniteur
  69. displayImage(monitor, image)
  70. end
  71.  
  72. -- Exécuter le programme
  73. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement