screenshot.lua - Screenshot System
Reference for `screenshot.lua`. Handles screenshot capture, metadata collection, format selection, and optional upload to BeamNG's media server.
Reference for screenshot.lua. Handles screenshot capture, metadata collection, format selection, and optional upload to BeamNG's media server.
Exports
| Key | Signature | Description |
|---|---|---|
doScreenshot | (batchTag?, upload?, path?, ext?) | Takes a screenshot with auto-naming or custom path |
publish | (batchTag?) | Takes and uploads a screenshot (requires online features) |
doSteamScreenshot | () | Triggers a Steam screenshot |
openScreenshotsFolderInExplorer | () | Opens the screenshots folder in OS file browser |
takeScreenShot | () | Standard screenshot (4x supersampling) |
takeBigScreenShot | () | Large screenshot (9x supersampling) |
takeHugeScreenShot | () | Maximum quality screenshot (36x, highest render settings) |
screenshotTaken | () | C++ callback: GPU snapshot complete, restore render settings |
screenshotSaved | (res, filename) | C++ callback: file written to disk |
M.doScreenshot | (batchTag, upload, path, ext) | (No description available) |
M.doSteamScreenshot | () | (No description available) |
M.openScreenshotsFolderInExplorer | () | (No description available) |
M.publish | (batchTag) | (No description available) |
M.screenshotSaved | (res, filename) | res == 0 means all good |
M.screenshotTaken | () | we revet some graphic settings in here only to return to a normal render state |
M.takeBigScreenShot | () | (No description available) |
M.takeHugeScreenShot | () | (No description available) |
M.takeScreenShot | () | (No description available) |
Internals
Metadata
getMetadataJson() collects and JSON-encodes:
- Build info: version, arch, build type/number, shipping flag
- Level name, game state
- Steam ID hash and player name (if online)
- Camera position and rotation
- OS, CPU, GPU info (including Vulkan status)
- Time of day
- Custom data from
onCollectScreenshotMetadatahook
Screenshot Path
Files are saved to screenshots/<date-folder>/screenshot_<datetime>[_N].<format> with auto-incrementing suffix to avoid overwrites. Format comes from settings.getValue("screenshotFormat").
Highest Quality Mode
takeHugeScreenShot temporarily overrides render settings:
$pref::TS::detailAdjust→ 20 (default 1.5)$pref::Terrain::lodScale→ 0.001 (default 0.75)- Ground cover scale → 8 (default 1)
- Sunsky texture size → 8192, shadow distance → 8000
- Settings restored in
screenshotTaken()callback
How It Works
- User triggers via keybind or Lua call.
doScreenshotfinds next available filename, collects metadata.- Calls C++
createScreenshot(path, format, supersampling, tiles, overlap, downsample, upload, metadata). - C++ captures the frame buffer, calls back
screenshotTaken()(restore settings) thenscreenshotSaved().
-- Standard screenshot
screenshot.takeScreenShot()
-- Custom path
screenshot.doScreenshot(nil, false, '/tmp/myshot', 'png')
-- Upload to BeamNG servers
screenshot.publish()Exported Variables
sc_GroundCoverScaleSaved- Exported variable - initialized asgetGroundCoverScale()sc_detailAdjustSaved- Exported variable - initialized asTorqueScriptLua.getVar("$pref::TS::detailAdjust")sc_lodScaleSaved- Exported variable - initialized asTorqueScriptLua.getVar("$pref::Terrain::lodScale")sc_sunskyShadowDistanceSaved- Exported variable - initialized assunsky.shadowDistancesc_sunskyTexSizeSaved- Exported variable - initialized assunsky.texSizescreenshotHighest- Exported variable - initialized ashighest
map.lua - Navigation Graph (AI Road Map)
Reference for `map.lua`. Builds and maintains the navigation graph (navgraph) used by AI traffic, GPS routing, and mission waypoints. Loads road data from DecalRoads and manual waypoints, then process
server/server - Level Loading & Game Server
Reference for `server/server.lua`. Manages level loading, mission lifecycle, physics initialization, and the loading screen. Despite the name, this is a local "server" - BeamNG runs a client-server ar