ludic/packages/ludic.weather/queries.ludic
Orkuncakilkaya 19fcf60599 wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run
ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
  1804 vars into 126 states, 64 into lets; 23498 edits in 460 files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 15:31:34 +03:00

38 lines
2.2 KiB
Text

# queries.ludic - what the world asks the sky
export function weather_state(weather_st: WeatherState) -> int { return weather_st.wx_state }
export function weather_next(weather_st: WeatherState) -> int { return weather_st.wx_next }
export function weather_left(weather_st: WeatherState) -> float { return weather_st.wx_left }
export function weather_amount(weather_st: WeatherState) -> float { return weather_st.wx_amount }
export function weather_forecast(weather_st: WeatherState) -> int { return weather_st.wx_forecast }
export function weather_forced(weather_st: WeatherState) -> bool { return weather_st.wx_forced }
export function weather_wind(weather_st: WeatherState) -> float { return weather_st.wx_wind }
export function weather_dir(weather_st: WeatherState) -> float { return weather_st.wx_dir }
export function weather_ground_wet(weather_st: WeatherState) -> float { return weather_st.wx_ground }
export function weather_flash(weather_st: WeatherState) -> float { return weather_st.wx_flash }
# rain or snow is falling, and more than a spit of it
export function weather_wet(weather_st: WeatherState) -> bool {
if weather_kind_count(weather_st) == 0 { return false }
return weather_st.wx_kinds[weather_st.wx_state].wet and weather_st.wx_amount > 0.3
}
export function weather_overcast(weather_st: WeatherState) -> float {
if weather_kind_count(weather_st) == 0 { return 0.0 }
return weather_st.wx_kinds[weather_st.wx_state].overcast * weather_st.wx_amount
}
export function weather_cold(weather_st: WeatherState) -> float {
if weather_kind_count(weather_st) == 0 { return 0.0 }
return weather_st.wx_kinds[weather_st.wx_state].cold * weather_st.wx_amount
}
export function weather_name(weather_st: WeatherState, k: int) -> string {
if k < 0 or k >= weather_kind_count(weather_st) { return "" }
return weather_st.wx_kinds[k].name
}
# the half hour after a front goes through, when the air is glass-clear
export function weather_after_front(weather_st: WeatherState) -> bool { return weather_st.wx_clear_t > 0.0 }
# yesterday had rain or snow in it (the valley's fog pools after a wet day)
export function weather_wet_yesterday(weather_st: WeatherState) -> bool { return weather_st.wx_wet_yesterday }