RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

server/commands - Camera & Input Commandsge_utils - Game Engine Utility Functionsmain.lua - GE Lua Entry Point & Game Loopmap.lua - Navigation Graph (AI Road Map)screenshot.lua - Screenshot Systemserver/server - Level Loading & Game ServerserverConnection - Client-Server Connection Manager`setSpawnpoint` - Default Spawn Point Persistence`simTimeAuthority` - Simulation Time & Bullet Time Control`spawn` - Vehicle Spawning & Safe Placement`suspensionFrequencyTester` - Suspension Natural Frequency Analysis
Activity ManagerAudio Bank ManagerAudio Ribbon SystemBus Route ManagerCamera SystemCore Chat (IRC)Core CheckpointsCore Command HandlerCoupler Camera ModifierDevices (RGB Peripherals)Dynamic PropsEnvironmentFlowgraph ManagerForestFun StuffGame ContextGame StateGround Marker ArrowsGround MarkersHardware InfoHighscoresHotlappingInventoryJob SystemLap TimesLevelsLoad Map CommandMetricsMod ManagerMultiseatMultiseat CameraMulti SpawnOnlinePaths (Camera Paths)Quick Access (Radial Menu)Recovery PromptRemote ControllerReplayRepositoryRope Visual TestScheme Command ServerCore SnapshotCore SoundsCore TerrainTraffic SignalsTrailer RespawnVehicle Active PoolingVehicle Bridge (GE ↔ VLua Communication)Vehicle MirrorsVehicle PaintsCore VehiclesVehicle TriggersVersion UpdateWeather SystemWindows Console

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionscore

Environment

Comprehensive environment control: time of day, sky colors, clouds, fog, precipitation, gravity, temperature, and ground model physics. Manages the full weather/environment pipeline for levels.

Comprehensive environment control: time of day, sky colors, clouds, fog, precipitation, gravity, temperature, and ground model physics. Manages the full weather/environment pipeline for levels.


Public API - State

FunctionSignatureDescription
M.getState() → table|nilReturns full environment state (time, wind, clouds, fog, rain, gravity, temperature).
M.setState(state)Applies a full environment state table. Fires onEnvironmentChanged hook. Note: fogDensity in state is divided by 1000 internally (UI uses scaled values).
M.requestState()Sends current state to UI via EnvironmentStateUpdate guihook.
M.reset()Reloads temperature curve, ground models, and sends state to UI.
M.reset_init()Restores environment to the state captured at mission start.
M.enableChanges(enabled)Enables/disables environment modification (blocks set calls when disabled).
M.canChange() → boolReturns whether environment changes are currently enabled.
M.getTimeOfDayOptions(levelIdentifier?) → tableReturns time-of-day options for a level via core_levels.getTimeOfDayOptions(). Defaults to current level.
M.getDefaultTimeOfDayOptions() → tableReturns the built-in defaultTimeOfDayOptions table.

Public API - Time of Day

FunctionSignatureDescription
M.setTimeOfDay(timeOfDay)Sets time, play, dayScale, nightScale, dayLength, azimuthOverride. Updates sky colors.
M.getTimeOfDay() → table|nilReturns current TimeOfDay object properties.
M.cycleTimeOfDay()Cycles time through three stops: daytime (<0.2) → evening (0.23) → night (0.5) → early afternoon (0.05) → repeat.

Public API - Sky / Shadows

FunctionSignatureDescription
M.getShadowDistance() → numberGets ScatterSky shadow draw distance.
M.setShadowDistance(v)Sets ScatterSky shadow draw distance.
M.getShadowSoftness() → numberGets ScatterSky shadow softness.
M.setShadowSoftness(v)Sets ScatterSky shadow softness.
M.getShadowLogWeight() → numberGets ScatterSky shadow log weight.
M.setShadowLogWeight(v)Sets ScatterSky shadow log weight.
M.getSkyBrightness() → numberGets ScatterSky brightness.
M.setSkyBrightness(v)Sets ScatterSky brightness.
M.getColorizeGradientFile() → stringGets gradient texture path for sky colorization.
M.setColorizeGradientFile(path)Sets gradient texture for sky colorization.
M.getSunScaleGradientFile() → stringGets gradient texture path for sun scale.
M.setSunScaleGradientFile(path)Sets gradient texture for sun scale.
M.getAmbientScaleGradientFile() → stringGets gradient texture path for ambient scale.
M.setAmbientScaleGradientFile(path)Sets gradient texture for ambient scale.
M.getFogScaleGradientFile() → stringGets gradient texture path for fog scale.
M.setFogScaleGradientFile(path)Sets gradient texture for fog scale.
M.getNightGradientFile() → stringGets gradient texture path for night sky color.
M.setNightGradientFile(path)Sets gradient texture for night sky color.
M.getNightFogGradientFile() → stringGets gradient texture path for night fog color.
M.setNightFogGradientFile(path)Sets gradient texture for night fog color.

Public API - Clouds

FunctionSignatureDescription
M.getWindSpeed() → numberGets first CloudLayer wind speed.
M.setWindSpeed(v)Sets first CloudLayer wind speed. Fires onEnvironmentChanged hook.
M.getCloudCover() → numberGets first CloudLayer coverage.
M.setCloudCover(v)Sets first CloudLayer coverage. Fires onEnvironmentChanged hook.
M.getCloudCoverByID(id) → numberGets cloud coverage by object ID.
M.setCloudCoverByID(id, v)Sets cloud coverage by object ID.
M.getCloudExposureByID(id) → numberGets cloud exposure by object ID.
M.setCloudExposureByID(id, v)Sets cloud exposure by object ID.
M.getCloudWindByID(id) → numberGets cloud wind by object ID.
M.setCloudWindByID(id, v)Sets cloud wind by object ID.
M.getCloudHeightByID(id) → numberGets cloud height by object ID.
M.setCloudHeightByID(id, v)Sets cloud height by object ID.

Public API - Fog / Gravity / Rain

FunctionSignatureDescription
M.getFogDensity() → numberGets LevelInfo fog density.
M.setFogDensity(v)Sets LevelInfo fog density. Fires onEnvironmentChanged hook.
M.getFogDensityOffset() → numberGets fog density offset.
M.setFogDensityOffset(v)Sets fog density offset.
M.getFogAtmosphereHeight() → numberGets fog atmosphere height.
M.setFogAtmosphereHeight(v)Sets fog atmosphere height.
M.getGravity() → numberGets world gravity (default -9.81).
M.setGravity(v)Sets world gravity. Updates LevelInfo and pushes to all objects via queueAllObjectLua. Fires onEnvironmentChanged hook.
M.getPrecipitation() → numberGets precipitation drop count.
M.setPrecipitation(v)Sets precipitation drop count.
M.getTemperatureK() → numberCurrent sea-level temperature in Kelvin.

Public API - Ground Models

FunctionSignatureDescription
M.reloadGroundModels(levelPath?)Reloads art/groundmodels.json + level-specific ground models.
M.dumpGroundModels()Writes all active ground models to groundmodels_dump.json.

Time-of-Day Presets

KeyValueLabel
sunrise0.775Sunrise
morning0.85Morning
earlyNoon0.9Early Noon
noon0.0Noon
lateNoon0.1Late Noon
afternoon0.175Afternoon
evening0.23Evening
sunset0.245Sunset
night0.5Night

Hooks

HookPurpose
M.onClientPreStartMissionCalled on ClientPreStartMission event
M.onClientPostStartMissionCalled on ClientPostStartMission event
M.onInitCalled on Init event
M.onUpdateCalled on Update event
M.onClientStartMissionCalled on ClientStartMission event
M.onClientEndMissionCalled on ClientEndMission event
M.onEditorEnabledCalled on EditorEnabled event
M.onFilesChangedReloads ground models when monitored JSON files change on disk.

Module State

VariableTypeDefault
M.groundModelstable{}
M.loadedGroundModelFilestable{}
M.defaultTimeOfDayOptionstablePreset time-of-day options array
M.timeOfDayKeyToTimetable{} - lookup from key name to time value

Usage Example

-- Set time to sunset
local tod = core_environment.getTimeOfDay()
tod.time = 0.245
tod.play = false
core_environment.setTimeOfDay(tod)

-- Change gravity to Moon-like
core_environment.setGravity(-1.62)

Key Internals

  • Sky colors are sampled from gradient textures via GBitmap pixel lookup at the current time value.
  • Ground models are keyed UPPERCASE; ASPHALT is always loaded first.
  • Temperature follows a piecewise-linear curve from LevelInfo:getTemperatureCurveC().
  • onFilesChanged auto-reloads ground models when JSON files change.

Dynamic Props

Replaces static forest items with interactive vehicle-based props at runtime using a pooling system. Props are spawned near the player and swapped back to forest items when out of range-enabling destr

Flowgraph Manager

Central manager for BeamNG's visual scripting system (flowgraphs). Handles creation, loading, serialization, and per-frame execution of flowgraph manager instances.

On this page

Public API - StatePublic API - Time of DayPublic API - Sky / ShadowsPublic API - CloudsPublic API - Fog / Gravity / RainPublic API - Ground ModelsTime-of-Day PresetsHooksModule StateUsage ExampleKey Internals