Rally Mission Settings
Class managing per-mission rally settings stored as a JSON file alongside mission data. Handles notebook filename selection, codriver selection, and persistence. Auto-creates defaults if the settings
Class managing per-mission rally settings stored as a JSON file alongside mission data. Handles notebook filename selection, codriver selection, and persistence. Auto-creates defaults if the settings file doesn't exist.
Constructor
local MissionSettings = require('gameplay/rally/notebook/missionSettings')
local settings = MissionSettings(missionDir)Public API
| Method | Signature | Returns | Description |
|---|---|---|---|
init | (missionDir) | nil | Stores mission directory |
fname | () | string | Returns settings file path |
load | (notebook?) | boolean | Loads settings from JSON; creates defaults if missing; validates codriver |
loadNotebook | () | object|nil | Loads the selected notebook file |
loadRacePath | () | object|nil | Loads race.race.json for the mission |
write | () | nil | Persists current settings to JSON |
setNotebookFilename | (filename) | nil | Sets notebook filename and saves |
getNotebookFilename | () | string | Returns current notebook filename |
getNotebookFullPath | () | string | Returns full path to notebook file |
setCodriverId | (codriverId) | nil | Sets active codriver by pk and saves |
getCodriverId | () | string | Returns active codriver pk |
getCodriverPk | () | string | Alias for getCodriverId |
onSerialize | () | table | Returns serializable settings |
onDeserialized | (data) | nil | Restores settings from data |
Internals
Default Settings
{
notebook = {
filename = rallyUtil.defaultNotebookFname,
codriverId = nil
}
}File Path
Settings are stored at {missionDir}/rally/settings.json (via rallyUtil.getMissionSettingsFile).
Load Flow
- If settings file doesn't exist → create with defaults and write
- Read JSON file
- Validate notebook filename:
- If missing or file not found → use first existing notebook, or default
- Validate codriver ID (if notebook passed):
- If codriver pk not found in notebook → use first codriver
- Re-read file after any corrections
- Clear legacy
codriverfield - Deserialize into object state
Notebook Discovery
listNotebooks(folder) scans {missionDir}/rally/notebooks/ for *.notebook.json files and returns sorted paths.
How It Works
- Created by
notebook.pathorrallyManagerwith a mission directory load(notebook)reads or creates the settings file, validates selections- The notebook and codriver selections determine which pacenotes and audio are used
- Changes via
setNotebookFilenameorsetCodriverIdimmediately persist to disk - Multiple re-reads during load ensure consistency after auto-corrections
Usage Example
local MissionSettings = require('gameplay/rally/notebook/missionSettings')
local settings = MissionSettings('/path/to/mission')
-- Load and validate
settings:load(notebook)
-- Get current notebook
local nbFilename = settings:getNotebookFilename()
local nb = settings:loadNotebook()
-- Switch codriver
settings:setCodriverId(codriver.pk)See Also
- Rally Codriver - Related reference
- Rally Pacenote - Related reference
- Pacenote Generator - Related reference
- Gameplay Systems Guide - Guide
Rally Codriver
Class representing a rally co-driver within a notebook. Each codriver has a name, language, voice setting, and unique persistent key (pk). Codrivers determine which language and voice are used for pac
Rally Pacenote
Core class representing a single pacenote in a rally notebook. Manages note text (freeform + structured), waypoints (corner start/end), audio compilation, validation, debug drawing, trigger types, and