Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Fonction pour afficher une image ASCII sur un moniteur
- local function displayImage(monitor, image)
- -- Efface le moniteur
- monitor.clear()
- -- Récupère la taille du moniteur
- local width, height = monitor.getSize()
- -- Parcourt chaque ligne de l'image
- for y, row in ipairs(image) do
- if y > height then break end -- Arrête si l'image dépasse la hauteur du moniteur
- -- Tronque ou remplit la ligne pour qu'elle corresponde à la largeur du moniteur
- local line = row:sub(1, width) -- Tronque si la ligne est trop longue
- if #line < width then
- line = line .. string.rep(" ", width - #line) -- Remplit avec des espaces si trop courte
- end
- monitor.setCursorPos(1, y)
- monitor.write(line)
- end
- end
- -- ASCII art à afficher
- local image = {
- "####################################################################################################",
- "####################################################################################################",
- "####################################################################################################",
- "####################################################################################################",
- "######################################+=-:......:-=+################################################",
- "##################################=:. -@@- .:=############################################",
- "###############################+. :%@@@@%: .+#########################################",
- "#############################=. .#@@@@@@@#. .=#######################################",
- "###########################*. .*@@@@@@@%. .*#####################################",
- "##########################- .+@@@@@@@@: .-. -####################################",
- "#########################- -@@@@@@@@: -@@@= -###################################",
- "########################- :@@@@@@@@=. :@@@@@@@: -##################################",
- "#######################*. .+@@@@@@@%: :%@@@@@@@@@%: .*#################################",
- "#######################. .*@@@@@@@%..#@@@@@@@@@@@@@#. .#################################",
- "######################+ +*. .#@@@@@@@@@@@@@@%:%@@@@@@@+ +################################",
- "######################= =@@@@+. :%@@@@@@@@@@@: :@@@@@@@@= =################################",
- "######################=.%@@@@@@@= +@@@@@@@@+ =@@@@@@@%.=################################",
- "######################= =@@@@@@@@: :%@@@@@@@@@@%: .+@@@@= =################################",
- "######################+ *@@@@@@@%:#@@@@@@@@@@@@@@#. .** +################################",
- "#######################. .#@@@@@@@@@@@@@%..%@@@@@@@*. .#################################",
- "#######################*. .%@@@@@@@@@@: :@@@@@@@@+. .*#################################",
- "########################- -@@@@@@@- -@@@@@@@@- -##################################",
- "#########################- .=@@@=. :@@@@@@@@=. -###################################",
- "##########################- .-. :%@@@@@@@+. -####################################",
- "###########################*. .#@@@@@@@*. .*#####################################",
- "#############################=. .*@@@@@@@#: .=#######################################",
- "###############################+. :%@@@@%: .+#########################################",
- "##################################=:. -@@- .:=############################################",
- "######################################+-::......::-+################################################",
- "####################################################################################################",
- "####################################################################################################",
- "####################################################################################################",
- "####################################################################################################",
- }
- -- Programme principal
- local function main()
- -- Trouve un moniteur connecté
- local monitor = peripheral.find("monitor")
- if not monitor then
- print("Erreur : Aucun moniteur trouvé.")
- return
- end
- -- Affiche l'image ASCII sur le moniteur
- displayImage(monitor, image)
- end
- -- Exécuter le programme
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement