## CALLBACKS
```js
onStart = () => {} // Runs once when the script starts.
onStop = () => {} // Runs on normal End; not guaranteed after an error or forced stop.
onPause = () => {} // Runs when the script is paused.
onResume = () => {} // Runs when the script resumes; variables are preserved.
onTick = (dt) => {} // Game update (~30 Hz); dt is seconds; stops during game pause.
tick = (milliseconds) => {} // Alternative update; milliseconds instead of seconds; defining both ticks runs both.
onFrame = (dt) => {} // Frame callback; dt is seconds; also runs during game pause.
onGamePause = () => {} // Runs when the game pauses, e.g. Esc.
onGameResume = () => {} // Runs when the game resumes.
onKeyDown = (key) => {} // New key press; key is a code such as "KeyH".
onKeyUp = (key) => {} // Key release; key is a KeyboardEvent.code string.
onMouseDown = (button, pos) => {} // Mouse press; button: 0 left, 1 middle, 2 right; pos: viewport {x,y}.
onMouseUp = (button, pos) => {} // Mouse release; button: 0 left, 1 middle, 2 right; pos: viewport {x,y}.
onEntitySpawn = (id, type) => {} // Entity appears; id is an integer; type is "Player" or "Traffic".
onEntityDespawn = (id) => {} // Entity disappears; its id is no longer valid.
onVehicleChanged = (id, type) => {} // Player model changes; type: Coupe, Bike, Bus or DriftCoupe.
onWorldLoaded = (style, seed) => {} // World changes; style is the biome name; seed is a string.
onPlayerRespawn = (id) => {} // Player resets/respawns; id is 1.
onWheelGroundedChange = (id, wheelIndex, grounded) => {} // Player wheel contact changes; wheelIndex starts at 0; grounded is boolean.
```
## APIS
```js
api.playParticleEffect(options) // Emits a burst; returns effect ID; metres/seconds; own script only.
api.createParticleEmitter(options) // Continuous emitter; returns ID; emitRate particles/second.
api.updateParticleEmitter(id, options) // Updates options; maxParticles is fixed; returns true.
api.stopParticleEmitter(id) // Stops emission; existing particles fade; returns true.
api.removeParticleEffect(id) // Removes effect immediately; returns false if not owned/missing.
api.clearParticles() // Removes this script's effects; returns number removed.
api.getParticleEffects() // Own effects: [{id,type,emitting,particleCount}].
api.getParticlePresets() // Option objects for smoke, dust, sparks, snow, confetti.
api.getParticleTextures() // soft, smoke, spark, circle, square, ring, star, heart, snow.
// Particle options: presetId, texture, position (or pos1/pos2), dir1/dir2, gravity; vectors accept [x,y,z] or {x,y,z}.
// minLifeTime/maxLifeTime: .01–60 seconds; minEmitPower/maxEmitPower: 0–10000 m/s; minSize/maxSize: .001–1000 metres.
// manualEmitCount: 0–8192; emitRate: 0–5000/second; maxParticles: 1–8192 (fixed capacity); hideDist: 0–100000 metres.
// attachTo: entity ID or null; attached pos/dir are local offsets when followRotation=true (default); emitted particles remain in world space.
// colorGradients: [{timeFraction:0..1,minColor:[r,g,b,a],maxColor?:[r,g,b,a]}]; RGB 0–255, alpha 0–1.
// sizeGradients/velocityGradients: [{timeFraction:0..1,factor:0..100,factor2?:0..100}]; 1–16 distinct stops, interpolated over lifetime.
// blendMode: 0 additive (ignores alpha), 1 standard, 2 additive, 3 multiply; no physics collisions.
// Budgets: 64 effects / 8192 reserved particles across scripts; full emitters skip births; free capacity with remove/clear.
// Game/script Pause freezes particles; Resume continues; End/error/world reload removes them. Default burst: 32; emitter: 30/s; life: .5–1s; size: .05–.15m.
api.getId() // Player ID (1).
api.getAllEntities() // Available IDs: {player:[...], traffic:[...]}; either array may be empty.
api.getEntityType(id) // Returns "Player" or "Traffic" for a valid id.
api.getVehicleTypePlayer(id = 1) // Returns Coupe, Bike, Bus or DriftCoupe; only player ID 1 is accepted.
api.getVehicleTypeTraffic(id) // Returns Model1, Model2, etc.; requires a traffic ID.
api.getVehicleTypes() // Returns selectable model names: {player:[...], traffic:[...]}.
api.setVehicle(id, name) // Changes model; player changes reload/reset the vehicle; returns true.
api.despawn(id) // Removes traffic; returns false for player/missing IDs, true on success.
api.getPosition(id) // World position {x,y,z}, in metres.
api.setPosition(id, x, y, z) // Teleports; also accepts [x,y,z] or {x,y,z}; returns true; excluded from trip distance.
api.getVelocity(id) // World velocity {xv,yv,zv}, in metres/second.
api.setVelocity(id, xv, yv, zv) // Also accepts [xv,yv,zv] or {xv,yv,zv}; player changes once, traffic holds until released.
api.getDistance(id1, id2) // 3D distance between two valid entities, in metres.
api.getSpeed(id) // Speed magnitude: {kph,mph}.
api.setSpeed(id, {kph}) // Pass exactly {kph:number} or {mph:number}; player changes once; traffic keeps road AI.
api.getTripDistance(id = 1) // Travel excluding teleports: {km,miles,meters}; traffic tracking begins when requested.
api.resetTripDistance(id = 1) // Resets tracked distance to zero; returns true.
api.getThrottle(id = 1) // Analogue throttle; positive forward, negative reverse.
api.getBrake(id = 1) // Returns [false,null], [true,"brake"] or [true,"handbrake"].
api.getSteering(id = 1) // Normalized steering: -1 to 1; positive left, negative right.
api.setSteering(id, value) // Holds steering from -1 to 1 until replaced/released; returns true.
api.getBoost(id = 1) // Returns whether boost is active.
api.setBoost(id, enabled) // Holds a boolean boost state; returns true.
api.getInput(id = 1) // Returns {throttle,brake,steering,handbrake,boost}.
api.setInput(id, {throttle, brake, steering, handbrake, boost}) // Partial object; throttle/steering: -1..1; others: 0..1; holds values; latest write wins.
api.releaseControl(id = 1) // Releases this script's input/velocity/speed overrides; returns true.
api.getWheelCount(id) // Bike: 2 (front, rear); other player wheels: FL, FR, RL, RR; traffic: 4 (FR, FL, RR, RL).
api.getWheelPosition(id, wheelIndex) // Wheel-centre world {x,y,z}; zero-based wheelIndex; available at distant detail levels.
api.isWheelGrounded(id, wheelIndex) // Returns boolean contact; player uses suspension, traffic uses terrain height.
api.getWheelSlip(id, wheelIndex) // Player tyre slip (documented 0..1); traffic always returns 0.
api.getWheelRPM(id, wheelIndex) // Wheel revolutions/minute; traffic derives this from speed and radius.
api.getWheelSteerAngle(id, wheelIndex) // Steering relative to maximum, -1..1; player rear wheels return 0.
api.getVersion() // Installed app version string.
api.getTime() // Returns Dawn, Day, Dusk or Night.
api.getWeather() // Returns Clear or Weather (overcast/weather state).
api.getSeason() // Returns Spring, Summer, Autumn or Winter; Driftmas stays Winter.
api.getWorldStyle() // Returns Hills, Dirt Roads, Inland Sections, Shorelines, Off-World or Driftmas.
api.getRoadsettings() // Returns {curves,style}; curves: Straight/Gentle/Normal/Winding; style: OffroadThin/OffroadWide/SingleThin/SingleWide/Autobahn1–4.
api.getRoadSettings() // Alias of getRoadsettings; Autobahn1 has one paved lane per direction.
api.getWorldSeed() // Current seed string.
api.worldReload() // Starts generation with current world settings/seed; returns true before completion.
api.isPaused() // Returns whether the game is paused; separate from script Pause.
api.setPaused(paused) // Pauses/resumes the game with a boolean; returns true.
api.getSetting(name) // Current value by full setting ID or unambiguous label/property name.
api.getSettings() // All available setting IDs, types, values and options; uiMin/uiMax/uiStep describe sliders only.
api.setCarSetting(name, value) // Sets tuning.* only; numeric values uncapped but finite; Scale must be positive; persists.
api.setSetting(name, value) // Sets one setting; numeric values uncapped but finite, Scale positive; valid types/options still apply; persists.
api.setSettings(values) // Batch {settingId:value,...}; validates all first; returns true; vehicle changes last; world changes need worldReload.
api.getRoadPosition(distance = 0) // Generated road centreline {x,y,z}; metres ahead of player (negative behind); beyond geometry throws.
api.getRoadWidth() // Full road width in metres.
api.isOnRoad(id) // Returns whether the entity is on the road.
api.getLaneCount() // Returns {multi,count}; multi means two carriageways; count is lanes per direction.
api.getLanePosition(lane, distance = 0) // Lane centre {x,y,z}; lane 0 is leftmost in travel direction; distance is metres ahead (negative behind).
api.getCurrentLaneIdx(id = 1) // Zero-based lane index, or null off-road.
api.getCamera() // Full camera state; overrides release on Pause/End, but mode changes persist.
api.getCameraModes() // Supported native camera mode names.
api.getCameraMode() // Current camera mode name.
api.setCameraMode(mode) // Selects a supported mode name (case-insensitive); persists; returns true.
api.getCameraPosition() // Camera world {x,y,z}, in metres.
api.setCameraPosition({x, y, z}) // Temporary world position; accepts {x,y,z}, [x,y,z] or x,y,z; returns true.
api.getCameraRotation() // World Euler {x,y,z}, radians, YXZ order.
api.setCameraRotation({x, y, z}) // Temporary YXZ Euler radians; object, array or x,y,z; takes precedence over target orientation.
api.getCameraTarget() // Target entity ID; default is player 1.
api.setCameraTarget(id) // Temporarily follows a valid entity ID; returns true.
api.getCameraFov() // Current field of view in degrees.
api.setCameraFov(degrees) // Temporary FOV override, 1..175 degrees; returns true.
api.getCameraZoom() // Current camera zoom multiplier.
api.setCameraZoom(zoom) // Temporary zoom, 0.1..10; returns true.
api.getCameraDistance() // Distance to target in metres, or requested override.
api.setCameraDistance(metres) // Temporary following distance, 0.1..10000 metres; returns true.
api.getCameraShake() // Continuous shake amount in metres; default 0; excludes temporary pulses.
api.setCameraShake(amount) // Continuous shake, 0..10 metres; 0 disables it; returns true.
api.shakeCamera(strength, duration) // Decaying shake pulse; strength: 0..10 metres; duration: 0.01..60 seconds; returns true.
api.getCameraLook() // Look target {yaw,pitch}, in radians.
api.setCameraLook(yaw, pitch) // Finite yaw and pitch in radians; pitch: -π/2..π/2; returns true.
api.resetCamera() // Clears this script's camera overrides and resets camera/user pose; returns true.
api.isKeyDown(key) // Physical or script-held key; accepts codes (KeyW, Space, ShiftRight) or letters ("w").
api.isKeyPressed(key) // True for a keydown event in this script frame only.
api.isKeyReleased(key) // True for a keyup event in this script frame only.
api.getMousePosition() // Mouse {x,y} in viewport pixels.
api.isMouseDown(button = 0) // Held mouse button; accepts 0..4 (0 left, 1 middle, 2 right).
api.pressKey(key) // Holds a virtual key until released or script Pause/End/failure; returns true.
api.releaseKey(key) // Releases this script's virtual key; other holds remain; returns true.
api.log(...values) // Writes values to Chat; objects use JSON; returns undefined.
api.now() // Wall-clock milliseconds since Unix epoch; continues during pauses.
console.log(...values) // Writes values to Chat; returns undefined.
console.info(...values) // Same as console.log; returns undefined.
console.warn(...values) // Logs with warning styling; returns undefined.
console.error(...values) // Logs with error styling without throwing; returns undefined.
console.clear() // Clears Program output in Chat; returns undefined.
setTimeout(fn, milliseconds, ...args) // Runs fn once after active-game milliseconds; returns timer ID; freezes during game/script pause.
setInterval(fn, milliseconds, ...args) // Repeats fn on eligible frames; returns timer ID; freezes during game/script pause.
clearTimeout(id) // Cancels a managed timeout or interval by ID; returns undefined.
clearInterval(id) // Cancels a managed interval or timeout by ID; returns undefined.
```
## GET/SET CAR SETTING PARAMETERS
```txt
audio.ambient
audio.brakes
audio.collisions
audio.controls
audio.engine
audio.master
audio.masterVehicle
audio.menu
audio.music
audio.roll
audio.skid
audio.traffic
audio.ui
audio.wind
driving.autodrive
driving.headlights
gamepad.autoBoost
gamepad.brakeSense
gamepad.controllerIndex
gamepad.controllerIndexWasSet
gamepad.deadzone
gamepad.directSteer
gamepad.gamepadType
gamepad.linearity
gamepad.mapping
gamepad.steerRange
gamepad.steerSmoothing
gameplay.accelerationFactor
gameplay.autodriveMode
gameplay.autodriveSpeedFactor
gameplay.automaticGears
gameplay.barriersDisabled
gameplay.brakingFactor
gameplay.cameraMode
gameplay.clockMode
gameplay.countersteer
gameplay.dirtParticlesEnabled
gameplay.driveSide
gameplay.driverSide
gameplay.fastRoadLanes
gameplay.fullscreen
gameplay.gearsEnabled
gameplay.gripFactor
gameplay.hidePromo
gameplay.hideUI
gameplay.hudPosition
gameplay.ice
gameplay.lockFirstPersonCamera
gameplay.maxZoomOutDistance
gameplay.minZoomOutDistance
gameplay.mirrorDetail
gameplay.mirrorTargetFPS
gameplay.odomMode
gameplay.pauseOnMenu
gameplay.pauseOnUnfocus
gameplay.rearMirrorEnabled
gameplay.roadWidth
gameplay.seatHeight
gameplay.seatPosition
gameplay.showConsole
gameplay.showDebug
gameplay.showFPS
gameplay.showInteriorHud
gameplay.showPosition
gameplay.showUpcomingRoad
gameplay.showWheel
gameplay.sideMirrorsEnabled
gameplay.softBrakeForce
gameplay.speedFactor
gameplay.steerAssist
gameplay.steeringFactor
gameplay.suspensionDampingFactor
gameplay.suspensionFactor
gameplay.temporaryManualOverride
gameplay.touchscreen
gameplay.trafficAmount
gameplay.trafficCollisionFactor
gameplay.trafficEnabled
gameplay.trailerCount
gameplay.units
gameplay.verticalFov
gameplay.wheelRotation
graphics.cameraRecenter
graphics.cameraSensitivity
graphics.cameraSmoothing
graphics.cameraUseMotionDir
graphics.cameraUseSteerDir
graphics.compileShaders
graphics.dashboardEnabled
graphics.detail
graphics.fovEffectStrength
graphics.fovEffects
graphics.glowEffects
graphics.maxFramerate
graphics.maxZoomOutDistance
graphics.minZoomOutDistance
graphics.mirrorDistance
graphics.mirrorEnabled
graphics.mirrorFramerate
graphics.mirrorResolution
graphics.motionDirBlend
graphics.renderScale
graphics.shadowDetail
graphics.snowEffects
graphics.steerDirBlend
graphics.trafficHeadlights
graphics.trafficHorizon
graphics.useNativeRenderScale
graphics.verticalFov
graphics.viewDistance
graphics.wheelSpray
keyboard.accelFactor
keyboard.doubleTapBoost
keyboard.lockedSteerMode
keyboard.lockedSteerSpeed
keyboard.mapping
keyboard.recenterSpeed
keyboard.softSteer
keyboard.steerSpeed
keyboard.toggleBoost
mouse.accelFactor
mouse.clickInputMode
mouse.currentSteer
mouse.doubleClickBoost
mouse.doubleClickInterval
mouse.linearity
mouse.mapping
mouse.showSteerIndicator
mouse.smoothing
mouse.steerBarWidth
mouse.useMouse
paint.hasPlates
paint.headlightCol
paint.metalTint
paint.primaryDiffuse
paint.primaryGloss
paint.primaryMetalness
paint.showPlates
paint.stickers
paint.wheelDiffuse
paint.wheelGloss
paint.wheelMetalness
paint.wheelType
paint.windowTint
scene.preset
scene.season
scene.time
scene.weather
system.bounce
system.bounceTempo
system.crackleDebug
system.crackleDebugB
system.enginePreference
system.gamepadNavigation
system.gearboxPreference
system.joystickNavigation
system.keyNavigation
system.language
system.pauseOnUnfocus
system.showDebug
traffic.density
traffic.lane
traffic.speed
tuning.accel
tuning.accelerationFactor
tuning.aeroFactor
tuning.axleOffset
tuning.boostFactor
tuning.brake
tuning.brakeBias
tuning.brakeResponse
tuning.cautionFactor
tuning.corneringCaution
tuning.corneringFactor
tuning.counterSteerAssist
tuning.damping
tuning.downforceFactor
tuning.drag
tuning.engineType
tuning.engineVolFactor
tuning.evAccel
tuning.evAccelBonus
tuning.evAccelFactor
tuning.evBoostFactor
tuning.evBoostRateFactor
tuning.evPowerBalance
tuning.evRateFactor
tuning.evRateInterval
tuning.evRateMin
tuning.evSpeedTargetOffset
tuning.evSpeedVolFalloff
tuning.hornRate
tuning.icDrive
tuning.icDriveMode
tuning.icGearbox
tuning.icMaxRPM
tuning.icMaxTorque
tuning.icSpeedFactor
tuning.jerk
tuning.kineticFrictionFactor
tuning.lockDiff
tuning.lockDiffOnlyRear
tuning.lonFrictionFactor
tuning.maxLinearAccel
tuning.maxRotAccel
tuning.maxSteer
tuning.minCautionFactor
tuning.peakSlipAngle
tuning.rearStability
tuning.reverse
tuning.rockInertia
tuning.rollResistance
tuning.scale
tuning.shockForce
tuning.shockTravel
tuning.speedFactor
tuning.steerAssist
tuning.steerInterval
tuning.targetDistFactor
tuning.topSpeed
tuning.tyreFriction
tuning.tyreStiffness
tuning.weightFactor
tuning.wheelMassFactor
vehicle.autodriveSide
vehicle.autodriveSideIndex
vehicle.ice
vehicle.mode
vehicle.seat
vehicle.seatAdjustment
vehicle.seatHeight
vehicle.showWheel
vehicle.speedControl
vehicle.speedControlMode
vehicle.speedControlTarget
vehicle.speedControlTargetMS
vehicle.speedFactor
vehicle.steerRotation
vehicle.steerRotationIndex
vehicle.steerSpeedFactor
vehicle.type
world.accumulatedDistance
world.laneStyle
world.roadStyle
world.roadWidth
world.scene
world.seed
world.startNode
```