Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local moniteur = peripheral.wrap("top")
- function obtenirDateHeureAPI()
- local response = http.get("https://worldtimeapi.org/api/timezone/Europe/Paris")
- if response then
- local data = response.readAll()
- response.close()
- local heure = textutils.unserializeJSON(data)
- local date = heure.datetime:sub(1, 10)
- local heureFormattee = heure.datetime:sub(12, 19)
- return date, heureFormattee
- else
- return "Erreur de connexion à l'API"
- end
- end
- function defilerTexte(texte, largeur)
- local texteDefile = texte
- while #texteDefile < largeur do
- texteDefile = texteDefile .. " " .. texte
- end
- local largeurTexte = #texteDefile
- local position = 1
- local direction = 1
- while true do
- local texteAffiche = texteDefile:sub(position, position + largeur - 1)
- moniteur.setCursorPos(1, 4)
- moniteur.write(texteAffiche)
- position = position + direction
- if position + largeur > largeurTexte then
- position = 1
- sleep(2)
- else
- sleep(0.5)
- end
- end
- end
- parallel.waitForAll(
- function()
- while true do
- local date, heure = obtenirDateHeureAPI()
- moniteur.setCursorPos(1, 1)
- moniteur.write("" .. heure)
- moniteur.setCursorPos(1, 2)
- moniteur.write("" .. date)
- sleep(1)
- end
- end,
- function()
- local texteDefile = {
- "Defqon.1 2024 : Power Of The Tribe",
- "Le nain va-t'il se connecté ?",
- "Oh un Nain ! Shorty sort de la !",
- "Timy Bourré ?",
- "Super Mr, Super Mr.. ",
- "Smacko es ses licorne ^^",
- "Hum Az_hog..",
- "Un Noichi ? NAN",
- }
- local largeurTexte = 30
- local indexTexte = 1
- while true do
- defilerTexte(texteDefile[indexTexte], largeurTexte)
- indexTexte = (indexTexte % #texteDefile) + 1
- sleep(600)
- end
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment