RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Gameplay AchievementGameplay CityDiscoverForce FieldGarage ModeMarker InteractionParking SystemGameplay Playmode MarkersGameplay PoliceGameplay RallyGameplay Rally LoopGameplay Raw POIsGameplay Skidpad TestSpeed Trap LeaderboardsSpeed Traps and CamerasGameplay StatisticsTaxi Ride SystemTraffic SystemVehicle PerformanceWalking
Drift Zone BoundsDrift Race PathDrift UI DisplayDrift Detection EngineDrift SystemDrift Quick MessagesDrift Save/LoadDrift ScoreboardDrift Scoring SystemDrift AudioDrift StallingDrift StatisticsDrift Stunt Zones

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 Extensionsgameplaydrift

Drift Save/Load

Reference for `gameplay_drift_saveLoad`, which loads drift spot definitions from level directories, manages per-spot score persistence, and handles career save integration.

Reference for gameplay_drift_saveLoad, which loads drift spot definitions from level directories, manages per-spot score persistence, and handles career save integration.


Overview

Scans level directories for drift spot data (*.driftSpot.json), loads spatial info, race paths, bounds, and save data (scores, objective completion). Provides save/load operations for both freeroam (settings/cloud/) and career (/career/) paths.


Exports

FunctionSignatureDescription
getDriftSpotsById() → tableLoad all spots for current level (cached)
getDriftSpotById(spotId) → tableGet a specific spot
loadAndSanitizeDriftFreeroamSpotsCurrMap() → tableSpots for current level only
loadDriftData(fileName)Load stunt zone data from JSON, set on stuntZones extension
saveDriftSpotsScoresForSpotById(spotId)Save scores for a spot
getPreviewWithFallback(dir) → stringFind preview image or return fallback
onCareerActive()Invalidate cached spots
onSaveCurrentSaveSlot(currentSavePath)Save dirty spots to career slot
M.getDriftSpotById(spotId)-
M.getDriftSpotsById()-
M.getPreviewWithFallback(dir)-
M.loadAndSanitizeDriftFreeroamSpotsCurrMap()-
M.loadDriftData(fileName)-
M.onCareerActive()-
M.onSaveCurrentSaveSlot(currentSavePath)-
M.saveDriftSpotsScoresForSpotById(spotId)-

Spot Data Structure

spotData = {
  id = "west_coast_usa/spot1",         -- level/directory path
  spatialInfo = {                       -- from spot.driftSpot.json
    lines = {
      lineOne = {pos, scl, rot, startDir, markerObjects},
      lineTwo = {pos, scl, rot, startDir, markerObjects}
    },
    bigMapTp = {pos, rot}              -- teleport position
  },
  racePath = "/levels/.../race.race.json",
  bounds = "/levels/.../bounds.sites.json",
  level = "west_coast_usa",
  info = {                              -- from info.json
    name = "Mountain Pass Drift",
    preview = "/levels/.../preview.jpg",
    objectives = {
      {id = "bronze", score = 500, rewards = {bmra = 10}},
      ...
    }
  },
  saveData = {                          -- from saved JSON
    scores = {{score=1500, licensePlate="ABC123", date=1234567}},
    objectivesCompleted = {bronze = true}
  },
  unlocked = true
}

How It Works

-- First call to getDriftSpotsById scans the level directory:
-- /levels/<level>/driftSpots/
--   spot1/
--     spot.driftSpot.json  -- spatial info, lines
--     info.json            -- name, objectives
--     race.race.json       -- race path
--     bounds.sites.json    -- zone boundaries
--     preview.jpg          -- thumbnail

-- Save data is loaded from:
-- Freeroam: settings/cloud/driftSpots/<spotId>.json
-- Career:   <savePath>/career/driftSpots/<spotId>.json

Score Saving

gameplay_drift_saveLoad.saveDriftSpotsScoresForSpotById("west_coast_usa/spot1")
-- Marks spot as dirty
-- In freeroam: saves immediately to settings/cloud/driftSpots/
-- In career: deferred to onSaveCurrentSaveSlot

Stunt Zone Loading

gameplay_drift_saveLoad.loadDriftData("/path/to/driftData.json")
-- Parses stuntZones array, converts pos/rot/scl to vec3/quat
-- Passes to gameplay_drift_stuntZones.setStuntZones()

Key Behaviors

  • Spot data is cached in spotsById; invalidated on onCareerActive()
  • Marker objects (cones, arrows) are hidden via obj:setHidden(true) on load
  • Scores are sorted descending; only top 10 retained
  • Preview resolution: checks preview.jpg, .png, .jpeg, falls back to noPreview.jpg
  • Career save uses dirty flag - only modified spots are saved on slot save
  • onAfterDriftSpotsLoaded hook fires in career mode for league/unlock evaluation

See Also

  • drift/bounds - Drift Zone Boundary Detection - Related reference
  • drift/destination - Race Path & Wrong-Way Detection - Related reference
  • drift/display - Drift UI & HUD Management - Related reference
  • Gameplay Systems Guide - Guide

Drift Quick Messages

Reference for `gameplay_drift_quickMessages`, which detects special drift achievements (close calls, big angles, long drifts, etc.) and awards bonus points with on-screen messages.

Drift Scoreboard

Reference for `gameplay_drift_scoreboard`, which accumulates detailed performance statistics during formal drift challenges for end-screen display.

On this page

OverviewExportsSpot Data StructureHow It WorksScore SavingStunt Zone LoadingKey BehaviorsSee Also