Weather Events

Estimated reading time: 2 minutes

The WeatherEvents module handles weather-related events and effects. It allows registering events on weather changes, modifying weather layers/effects, and adding custom weather types.

Access via maplebirch.dynamic.Weather or shortcut maplebirchFrameworks.addWeatherEvent().

Tip

Layer/effect changes must be registered before the framework's :passagestart phase. Using the recommended script load method ensures correct timing.

Core API

regWeatherEvent(eventId, options)

Register a new weather event.

maplebirch.dynamic.regWeatherEvent("rainyDay", {
  condition: () => Weather.name === "rain",
  onEnter: () => {
    V.isRaining = true;
    Wikifier.wikifyEval('<<notify "开始下雨了">>');
  },
  onExit: () => {
    V.isRaining = false;
    Wikifier.wikifyEval('<<notify "雨停了">>');
  },
  priority: 5,
  once: false,
});

delWeatherEvent(eventId)

Unregister a weather event.

maplebirch.dynamic.delWeatherEvent("rainyDay");

addWeather(data)

Add custom weather types or exceptions.

maplebirch.dynamic.addWeather({
  name: "acidRain",
  iconType: "acid",
  value: 10,
  probability: { summer: 0.1, winter: 0.05, spring: 0.2, autumn: 0.15 },
  cloudCount: { small: () => random(5, 10), large: () => random(2, 5) },
  tanningModifier: -0.5,
  overcast: 0.8,
  precipitationIntensity: 0.7,
  visibility: 0.4,
});

Event Options

OptionTypeDescription
conditionfunctionTrigger condition, returns boolean
onEnterfunctionCalled when condition becomes true
onExitfunctionCalled when condition becomes false
oncebooleanTrigger only once
prioritynumberHigher runs first