Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/OdintheDoggo/GodotNWS/llms.txt

Use this file to discover all available pages before exploring further.

The Nws singleton provides two forecast methods: a daily forecast that groups weather into named periods (such as “Tonight” or “Tuesday”) and an hourly forecast that covers each hour individually. Both methods are asynchronous and return their data through a signal. location_setup_complete must have fired before calling either method.

Daily Forecast

fetch_forecast(fetch_images: bool)

Fetches the daily forecast for the configured location and emits forecast_fetched with an array of ForecastPeriod resources. The NWS daily forecast typically covers seven days, broken into day and night periods.
fetch_images
bool
required
When true, the icon image for each forecast period is downloaded and stored in ForecastPeriod.icon as an ImageTexture. The signal fires only after all icon images have loaded. When false, ForecastPeriod.icon is null but ForecastPeriod.iconUrl is still populated, allowing you to load images later on demand.

Signal: forecast_fetched(periods: Array[ForecastPeriod])

Emitted when the daily forecast data — and all icon images, if requested — is ready.
periods
Array[ForecastPeriod]
An array of ForecastPeriod resources, one per forecast period. Each resource exposes the following fields:
When fetch_images is true, icon downloads are asynchronous. The signal fires after all icons are loaded, but the periods array may not be in chronological order. Sort by ForecastPeriod.number to restore the correct sequence.

Code Example

extends Node

func _ready() -> void:
    Nws.location_setup_complete.connect(_on_ready)
    Nws.setup(39.7456, -97.0892)

func _on_ready() -> void:
    Nws.forecast_fetched.connect(_on_forecast)
    Nws.fetch_forecast(true)

func _on_forecast(periods: Array[ForecastPeriod]) -> void:
    # Sort by period number to ensure chronological order
    periods.sort_custom(func(a, b): return a.number < b.number)
    for period in periods:
        print("%s: %d°%s%s" % [
            period.name,
            period.temperature,
            period.temperatureUnit,
            period.shortForecast
        ])

Hourly Forecast

fetch_hourly_forecast(fetch_images: bool)

Fetches the hourly forecast for the configured location and emits hourly_forecast_fetched with an array of HourlyForecastPeriod resources. The NWS hourly forecast typically covers the next 156 hours (six and a half days).
fetch_images
bool
required
When true, the icon image for each hourly period is downloaded and stored in HourlyForecastPeriod.icon. The signal fires only after all icons have loaded. When false, HourlyForecastPeriod.icon is null but iconUrl is still set.

Signal: hourly_forecast_fetched(periods: Array[HourlyForecastPeriod])

Emitted when the hourly forecast data — and all icon images, if requested — is ready.
periods
Array[HourlyForecastPeriod]
An array of HourlyForecastPeriod resources, one per hour. Each resource exposes the following fields:
When fetch_images is true, sort results by HourlyForecastPeriod.number after receiving the signal, as concurrent image downloads may reorder the array.

Code Example

extends Node

func _ready() -> void:
    Nws.location_setup_complete.connect(_on_ready)
    Nws.setup(39.7456, -97.0892)

func _on_ready() -> void:
    Nws.hourly_forecast_fetched.connect(_on_hourly)
    # Skip icon downloads for a fast, lightweight fetch
    Nws.fetch_hourly_forecast(false)

func _on_hourly(periods: Array[HourlyForecastPeriod]) -> void:
    # periods are in order when fetch_images is false
    for period in periods.slice(0, 24):
        print("Hour %d: %d°%s, %d%% precip, humidity %d%%" % [
            period.number,
            period.temperature,
            period.temperatureUnit,
            period.precipitationChance,
            period.relativeHumidity
        ])

Build docs developers (and LLMs) love