API ReferenceGE Extensionscore
Weather System
Loads and applies weather presets that modify scene object properties (fog, sky, lighting). Supports instant activation or smooth time-based transitions.
Loads and applies weather presets that modify scene object properties (fog, sky, lighting). Supports instant activation or smooth time-based transitions.
Public API
| Function | Signature | Description |
|---|---|---|
M.activate | (presetName) | Instantly applies a weather preset |
M.switchWeather | (presetName, t?) | Smoothly transitions to a preset over t seconds (default 15) |
M.getPresets | () | Returns an array of available preset names |
M.getCurrentWeatherPreset | () | Returns the name of the currently selected preset |
M.dumpWeather | () | Dumps all preset data to the console |
Hooks
| Hook | Description |
|---|---|
M.onExtensionLoaded | Resets state and loads presets |
M.onClientPostStartMission | Reloads presets when a level starts |
M.onPreRender | Updates interpolation during smooth weather transitions |
Preset Format
Presets are JSON files in art/weather/ (global) or levels/<name>/weather/ (level-specific). Structure:
{
"Clear": {
"ScatterSky": {
"brightness": 1.0,
"fogAmount": 0.1
},
"LevelInfo": {
"fogDensity": 0.001
}
}
}Each key is a scene object class, values are attribute name → target value mappings. Supported types: float, int, ColorF, Point4F, Point3F/vec3, and string.
Usage Example
-- Instant weather change
core_weather.activate("Foggy")
-- Smooth 10-second transition
core_weather.switchWeather("Rainy", 10)
-- List available presets
local presets = core_weather.getPresets()
for _, name in ipairs(presets) do print(name) end