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
Crawl BoundariesCrawl Flowgraph BridgeCrawl DebugCrawl UI DisplayCrawl Flowgraph BridgeCrawl SystemCrawl Save SystemCrawl Engine

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 Extensionsgameplaycrawl

Crawl Save System

Reference for `gameplay_crawl_saveSystem`, which handles loading, saving, serialization, and caching of crawl trail data (trails, boundaries, paths, starting positions) as well as player score persist

Reference for gameplay_crawl_saveSystem, which handles loading, saving, serialization, and caching of crawl trail data (trails, boundaries, paths, starting positions) as well as player score persistence.


Overview

Provides a complete data layer for the crawl system. Manages JSON file I/O with lazy-loading cache, serialization/deserialization of all crawl data types, and a player save system for tracking best scores across freeroam and career modes.


Data Types

TypeFile PatternDescription
Trail*.trail.jsonTrail definition: references to path, boundary, starting position
Boundary*.boundary.jsonZone boundary for crawl area
Path*.path.jsonSequence of path nodes with positions, rotations, radii
Starting Position*.startingPosition.jsonSpawn point with transform and icon position

Core Exports

Loading / Getters

FunctionSignatureDescription
getTrailById(trailId)Load and cache a trail by file path
getBoundaryById(boundaryId)Load and cache a boundary
getPathById(pathId)Load and cache a path
getStartingPositionById(startingPositionId)Load and cache a starting position
getAllTrails()Get all trails for the current level
getAllBoundaries()Get all boundaries for the current level
getAllPaths()Get all paths for the current level
getAllStartingPositions()Get all starting positions
getCurrentLevelCrawlPath()Get the crawl data directory for the current level
clearCache(type)Clear cached data (specific type or all)

Saving

FunctionSignatureDescription
saveTrail(trail, filePath)Serialize and save a trail
saveBoundary(boundary, filePath)Serialize and save a boundary
savePath(path, filePath)Serialize and save a path
saveStartingPosition(startingPosition, filePath)Serialize and save a starting position
loadCrawlData(filename)Load a crawl data file (lists of trail references)
saveCrawlData(saveData, filepath)Save a crawl data file

Player Scores

FunctionSignatureDescription
addNewPlayerScore(trailId, time, penaltyPoints)Record a new score attempt
getPlayerTrailStats(trailId)Get best time, best points, attempts
resetPlayerTrailScores(trailId)Reset all scores for a trail
getPlayerCrawlTrailById(trailId)Get player trail data
getPlayerCrawlTrailsById()Get all player trail data
ensurePlayerSaveDirectories()Create save directories if missing
isTrailFromMission(trail)Check if trail is mission-sourced

File Structure

Crawl data lives under /levels/<levelName>/crawls/ with typed file extensions:

/levels/johnson_valley/crawls/
  ridgeway.trail.json
  ridgeway.boundary.json
  ridgeway.path.json
  ridgeway.startingPosition.json

Player scores are saved in:

  • Freeroam: settings/cloud/crawlTrails/
  • Career: <savePath>/career/crawlTrails/

How It Works

-- Load a trail and its dependencies
local trail = gameplay_crawl_saveSystem.getTrailById("/levels/jv/crawls/test.trail.json")
local boundary = gameplay_crawl_saveSystem.getBoundaryById(trail.boundaryId)
local path = gameplay_crawl_saveSystem.getPathById(trail.pathId)

-- Save a new trail
gameplay_crawl_saveSystem.saveTrail(trailData, "/levels/jv/crawls/new.trail.json")

-- Record a player score
gameplay_crawl_saveSystem.addNewPlayerScore(trailId, 142.5, 15)

-- Get player stats
local stats = gameplay_crawl_saveSystem.getPlayerTrailStats(trailId)
-- stats.bestTime, stats.bestPenaltyPoints, stats.attempts

Key Behaviors

  • Lazy loading with cache - Files are loaded on first access and cached by file path
  • Auto-metadata - Loaded items get _filePath, _fileName, _dir, _ext fields
  • Boundaries are deserialized using gameplay/sites/zone module with onDeserialized
  • Path nodes deserialize positions as vec3 and rotations as quat
  • Player scores track both best time and best penalty points independently
  • Career scores are saved via onSaveCurrentSaveSlot hook, freeroam scores save immediately
  • Score improvements are tracked: addNewPlayerScore returns isNewBestTime / isNewBestPenaltyPoints

File Discovery

FunctionSignatureDescription
getAllTrailFiles(levelPath)Returns all .trail.json files for a level
getAllBoundaryFiles(levelPath)Returns all .boundary.json files for a level
getAllPathFiles(levelPath)Returns all .path.json files for a level
getAllStartingPositionFiles(levelPath)Returns all .startingPosition.json files for a level

Utilities

FunctionSignatureDescription
isTrailFromMission(trail) → boolChecks if a trail originates from a mission
cleanup()Clears all cached data and player scores
savePlayerCrawlTrailScoresForTrailById(trailId)Saves player scores for a specific trail to disk

Hooks / Lifecycle

FunctionDescription
onCareerActiveLoads/unloads career-specific score data
onSaveCurrentSaveSlotPersists career crawl scores into save slot
M.addNewPlayerScore(trailId, time, penaltyPoints)
M.cleanup()
M.clearCache(type)
M.ensurePlayerSaveDirectories()
M.getAllBoundaries()
M.getAllBoundaryFiles(levelPath)
M.getAllPathFiles(levelPath)
M.getAllPaths()
M.getAllStartingPositionFiles(levelPath)
M.getAllStartingPositions()
M.getAllTrailFiles(levelPath)
M.getAllTrails()
M.getBoundaryById(boundaryId)
M.getCurrentLevelCrawlPath()
M.getPathById(pathId)
M.getPlayerCrawlTrailById(trailId)
M.getPlayerCrawlTrailsById()
M.getPlayerTrailStats(trailId)
M.getStartingPositionById(startingPositionId, trail)
M.getTrailById(trailId)
M.isTrailFromMission(trail)
M.loadCrawlData(filename)
M.onCareerActive()
M.onSaveCurrentSaveSlot(currentSavePath)
M.resetPlayerTrailScores(trailId)
M.saveBoundary(boundary, filePath)
M.saveCrawlData(saveData, filepath)
M.savePath(path, filePath)
M.savePlayerCrawlTrailScoresForTrailById(trailId)
M.saveStartingPosition(startingPosition, filePath)
M.saveTrail(trail, filePath)

See Also

  • crawl/boundary - Crawl Boundary System - Related reference
  • crawl/crawlFlowgraphBridge - Crawl Flowgraph Bridge (Legacy) - Related reference
  • crawl/debug - Crawl Debug Window - Related reference
  • Gameplay Systems Guide - Guide

Crawl System

Reference for `gameplay_crawl_general`, the main manager for rock crawling trails. Handles trail setup, crawl lifecycle, POI registration, big map integration, activity dialogs, and score persistence.

Crawl Engine

Reference for `gameplay_crawl_utils`, the core runtime engine for rock crawling gameplay. Handles crawl state management, pathnode detection, penalty/infraction system, marker rendering, vehicle track

On this page

OverviewData TypesCore ExportsLoading / GettersSavingPlayer ScoresFile StructureHow It WorksKey BehaviorsFile DiscoveryUtilitiesHooks / LifecycleSee Also