Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m = peripheral.find("monitor")
- term.redirect(m)
- term.clear()
- m.setTextColour(colors.yellow)
- m.setBackgroundColour(colors.black)
- -- Définir une échelle fixe
- m.setTextScale(5)
- -- Function to get weather
- local function getWeather()
- local success, weather = commands.exec("weather query")
- if success then
- if weather:find("rain") then
- return "rainy"
- elseif weather:find("thunder") then
- return "thunder"
- else
- return "sunny"
- end
- end
- return "???"
- end
- -- Function to center text on the monitor
- local function centerText(text, line)
- local w, h = term.getSize()
- local x = math.floor((w - #text) / 2) + 1
- return x, line
- end
- -- Main loop
- while true do
- term.clear()
- -- Affichage de l'heure
- local time = os.time()
- local formattedTime = textutils.formatTime(time, true)
- local x, y = centerText(formattedTime, math.floor(h / 2))
- term.setCursorPos(x, y)
- term.write(formattedTime)
- -- Affichage de la météo
- local weather = getWeather()
- local wx, wy = centerText(weather, math.floor(h / 2) + 2)
- term.setCursorPos(wx, wy)
- term.write(weather)
- os.sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement