Change the environment from scripts
All ten scripting adapters expose Game.scene.getEnvironment(),
Game.scene.setEnvironment(settings) and Game.scene.setSkyTexture(path).
These calls target the loaded scene, including from global startup scripts, scene
startup scripts, and object component scripts. They work in Play, Play Solo and Run.
CSS-only assets have no executable callbacks; HTML uses inline JavaScript.
- Copy both daytime and nighttime 2:1 panoramas into your project, for example
assets/skies/day.hdrandassets/skies/night.hdr, before starting Play. Runtime scripts use the immutable play snapshot; they cannot download an image or select a file outside it. - Create a Lua script using Explorer's scripting commands. Attach it as a Scene Startup Script for the scene, or select an object and use + Add Component to attach the script. See the language guides for other languages and their toolchains.
- Use the following script and start Play with an active camera and visible geometry:
return {
Start = function()
Game.scene.setEnvironment({
enabled = true,
sky_image = 'assets/skies/day.hdr',
rotation_degrees = 45,
exposure = 0,
ambient_color = {1, 1, 1},
ambient_intensity = 0.12,
sun_color = {1, 0.95, 0.85},
sun_intensity = 1,
sun_direction = {0.3, 0.8, 0.4},
haze_color = {0.6, 0.7, 0.8},
haze_density = 0.01,
haze_start = 20
})
print(Game.scene.getEnvironment().sky_image)
end
}The next game frame shows the daytime sky, sun lighting and distance haze. The
console prints assets/skies/day.hdr. To switch skies during a later callback:
Game.scene.setSkyTexture('assets/skies/night.hdr')
Game.scene.setEnvironment({sun_intensity = 0, ambient_intensity = 0.06})setEnvironment applies a partial update: omitted fields keep their current values.
It validates the entire resulting environment and applies all supplied fields
atomically. Unknown fields, wrong types and invalid values raise a script error
without changing the environment. getEnvironment returns a fresh copy of the live
settings; editing that copy alone has no effect. Reads immediately see successful
updates, including earlier updates from other scripts. Nine adapters return all
settings from setters too; C setters return void.
setSkyTexture changes only sky_image; it does not enable a disabled environment
or change lighting. Use an empty string to clear the panorama and show the
configured solid or daylight sky. Set enabled=false to return to the built-in
3D sky and default lighting. Set sky_hidden=true to hide the sky and clouds. These runtime changes do
not save back to the editor scene or appear in Apply Runtime Changes. Stop and
restart Play to restore the editor's settings.
| Setting | Type and accepted values |
|---|---|
enabled | Boolean. Enables the custom sky, scene ambient light, sun light and haze. |
sky_hidden | Boolean, false by default. True hides the sky and clouds. |
sky_procedural | Boolean, false by default. In a custom environment with an empty sky_image, true uses daylight and false uses sky_color. |
clouds_enabled | Boolean, false by default. Enables the volumetric layer independently of enabled. |
cloud_coverage | Number from 0 to 1, defaults to 0.55. Zero gives a clear sky. |
cloud_density | Number from 0 to 4, defaults to 1. Controls opacity. Zero gives a clear sky. |
cloud_altitude | Number from -100,000 to 100,000, defaults to 180. Layer base along world Y. |
cloud_thickness | Number from 1 to 20,000, defaults to 90. Layer depth in world units. |
cloud_scale | Number from 1 to 20,000, defaults to 240. Size of cloud features in world units. |
sky_image | Project-relative HDR, PNG, JPEG or TGA path with / separators; empty clears it. Absolute paths, backslashes, drive prefixes, empty path segments, . and .. are rejected. |
sky_color | Three finite, non-negative RGB numbers. Used for a solid custom sky. |
rotation_degrees | Finite panorama rotation in degrees. |
exposure | Finite sky-image exposure in stops, from -20 to 20. |
ambient_color | Three finite, non-negative RGB numbers. |
ambient_intensity | Finite, non-negative ambient strength. |
sun_color | Three finite, non-negative RGB numbers. |
sun_intensity | Finite, non-negative directional light strength. |
sun_direction | Three finite numbers pointing from a surface towards the sun; squared length must exceed 0.000001 and remain finite. |
haze_color | Three finite, non-negative RGB numbers. |
haze_density | Finite, non-negative density; zero disables haze. |
haze_start | Finite, non-negative starting distance in world units. |
wind | A partial object with enabled, strength (two speeds from 0 to 100 m/s), and direction (two clockwise bearings from 0° to 360°). Null removes Wind. Read live world-space velocity with getEnvironment("wind_velocity"). |
time | Optional partial object when updating. Fields are enabled (default false), start_hour (0–24, default 12), cycle_seconds (1–86,400, default 120), sky_turns_per_day (integer from -8 to 8, default 1) and project-relative night_image, sunrise_image and sunset_image paths. Use an empty string to clear a phase image. |
Script adapters that accept settings objects can change the cycle using a partial time object. For example, from JavaScript:
Game.scene.setEnvironment({
enabled: true,
time: { enabled: true, start_hour: 18, cycle_seconds: 24 }
});getEnvironment().time returns the configured values. The rendered clock adds elapsed gameplay time to start_hour, so a change mid-session uses the time already elapsed. The C field API uses scalar values. Configure the cycle in the editor for C projects.
Colors may exceed 1 for HDR lighting. Values must fit the engine's 32-bit float representation. Sky rotation does not rotate the sun. The sky remains a background, so changing it does not generate reflections or image-based lighting.