|
|
| Line 30: |
Line 30: |
| {{Note|This function only works with standard vehicle models. For custom models, it will return the audio settings of the parent model.}} | | {{Note|This function only works with standard vehicle models. For custom models, it will return the audio settings of the parent model.}} |
|
| |
|
| ==Examples== | | ==Example== |
|
| |
|
| ===Example 1: Basic Audio Settings Retrieval===
| |
| <syntaxhighlight lang="lua"> | | <syntaxhighlight lang="lua"> |
| -- Get audio settings for Infernus (model 411) | | -- Retrieve and display the engine-on sound bank ID for Infernus (model 411) |
| local audioSettings = getVehicleModelAudioSettings(411) | | local settings = getVehicleModelAudioSettings(411) |
| if audioSettings then | | if settings then |
| outputChatBox("Infernus engine on sound bank: " .. audioSettings["engine-on-soundbank-id"]) | | outputChatBox("Infernus engine sound ID: " .. tostring(settings["engine-on-soundbank-id"])) |
| outputChatBox("Infernus engine off sound bank: " .. audioSettings["engine-off-soundbank-id"])
| |
| outputChatBox("Infernus horn tone: " .. audioSettings["horn-ton"])
| |
| else | | else |
| outputChatBox("Failed to retrieve audio settings for Infernus") | | outputChatBox("Failed to retrieve audio settings.") |
| end | | end |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
|
| ===Example 2: Compare Audio Settings Between Models===
| |
| <syntaxhighlight lang="lua">
| |
| -- Compare audio settings between different vehicle models
| |
| local models = {411, 506, 451, 602} -- Infernus, Super GT, Turismo, Alpha
| |
| local modelNames = {"Infernus", "Super GT", "Turismo", "Alpha"}
| |
|
| |
| outputChatBox("=== Vehicle Audio Comparison ===")
| |
| for i, modelID in ipairs(models) do
| |
| local audioSettings = getVehicleModelAudioSettings(modelID)
| |
| if audioSettings then
| |
| outputChatBox(modelNames[i] .. ":")
| |
| outputChatBox(" Engine On Bank: " .. audioSettings["engine-on-soundbank-id"])
| |
| outputChatBox(" Engine Off Bank: " .. audioSettings["engine-off-soundbank-id"])
| |
| outputChatBox(" Horn Volume Delta: " .. audioSettings["horn-volume-delta"])
| |
| outputChatBox(" Radio Type: " .. audioSettings["radio-type"])
| |
| outputChatBox("---")
| |
| end
| |
| end
| |
| </syntaxhighlight>
| |
|
| |
| ===Example 3: Audio Settings Inspector===
| |
| <syntaxhighlight lang="lua">
| |
| -- Function to display all audio properties of a vehicle model
| |
| function inspectVehicleAudio(modelID)
| |
| local audioSettings = getVehicleModelAudioSettings(modelID)
| |
| if not audioSettings then
| |
| outputChatBox("Invalid model ID or failed to retrieve audio settings")
| |
| return false
| |
| end
| |
|
| |
| outputChatBox("=== Audio Settings for Model " .. modelID .. " ===")
| |
| for property, value in pairs(audioSettings) do
| |
| outputChatBox(property .. ": " .. tostring(value))
| |
| end
| |
|
| |
| return true
| |
| end
| |
|
| |
| -- Example usage
| |
| inspectVehicleAudio(411) -- Inspect Infernus audio settings
| |
| </syntaxhighlight>
| |
|
| |
| ===Example 4: Audio Profile Backup System===
| |
| <syntaxhighlight lang="lua">
| |
| -- Function to backup audio settings for multiple models
| |
| function backupAudioSettings(models)
| |
| local backup = {}
| |
|
| |
| for _, modelID in ipairs(models) do
| |
| local audioSettings = getVehicleModelAudioSettings(modelID)
| |
| if audioSettings then
| |
| backup[modelID] = audioSettings
| |
| outputChatBox("Backed up audio settings for model " .. modelID)
| |
| else
| |
| outputChatBox("Failed to backup audio settings for model " .. modelID)
| |
| end
| |
| end
| |
|
| |
| return backup
| |
| end
| |
|
| |
| -- Function to display backup information
| |
| function displayBackupInfo(backup)
| |
| outputChatBox("=== Audio Settings Backup ===")
| |
| for modelID, settings in pairs(backup) do
| |
| outputChatBox("Model " .. modelID .. " has " .. table.size(settings) .. " audio properties")
| |
| end
| |
| end
| |
|
| |
| -- Example usage
| |
| local sportsCars = {411, 506, 451, 602}
| |
| local audioBackup = backupAudioSettings(sportsCars)
| |
| displayBackupInfo(audioBackup)
| |
| </syntaxhighlight>
| |
|
| |
| ===Example 5: Audio Settings Validation===
| |
| <syntaxhighlight lang="lua">
| |
| -- Function to validate audio settings and check for potential issues
| |
| function validateAudioSettings(modelID)
| |
| local audioSettings = getVehicleModelAudioSettings(modelID)
| |
| if not audioSettings then
| |
| outputChatBox("Model " .. modelID .. ": Invalid model or failed to retrieve settings")
| |
| return false
| |
| end
| |
|
| |
| local issues = {}
| |
|
| |
| -- Check engine sound bank IDs
| |
| if audioSettings["engine-on-soundbank-id"] > 410 then
| |
| table.insert(issues, "Engine-on sound bank ID exceeds safe limit (410)")
| |
| end
| |
|
| |
| if audioSettings["engine-off-soundbank-id"] > 410 then
| |
| table.insert(issues, "Engine-off sound bank ID exceeds safe limit (410)")
| |
| end
| |
|
| |
| -- Check for unusual values
| |
| if audioSettings["horn-volume-delta"] < 0 then
| |
| table.insert(issues, "Horn volume delta is negative")
| |
| end
| |
|
| |
| if #issues > 0 then
| |
| outputChatBox("Model " .. modelID .. " audio issues found:")
| |
| for _, issue in ipairs(issues) do
| |
| outputChatBox(" - " .. issue)
| |
| end
| |
| return false
| |
| else
| |
| outputChatBox("Model " .. modelID .. " audio settings are valid")
| |
| return true
| |
| end
| |
| end
| |
|
| |
| -- Validate audio settings for multiple models
| |
| local modelsToCheck = {411, 560, 562, 451}
| |
| for _, modelID in ipairs(modelsToCheck) do
| |
| validateAudioSettings(modelID)
| |
| end
| |
| </syntaxhighlight>
| |
|
| |
|
| ==See Also== | | ==See Also== |
ADDED/UPDATED IN VERSION 1.6.0
r23140:
This function retrieves audio properties for a specific vehicle model. It allows inspection of various vehicle sound settings such as engine sounds, horn characteristics, door sounds, and radio settings.
Syntax
table getVehicleModelAudioSettings ( int modelID )
Required Arguments
- modelID: The vehicle model ID to retrieve audio settings for
Returns
Returns a table containing audio settings if successful, false otherwise. The returned table contains the following properties:
- sound-type - Sound effect type
- engine-on-soundbank-id - Engine startup sound bank ID (0-410)
- engine-off-soundbank-id - Engine shutdown sound bank ID (0-410)
- bass-setting - Bass settings
- bass-eq - Bass equalizer
- field-c - Field C parameter
- horn-ton - Horn tone
- horn-high - Horn high frequency
- engine-upgrade - Engine upgrade sound effect
- door-sound - Door sound effects
- radio-num - Radio number
- radio-type - Radio type
- vehicle-type-for-audio - Audio vehicle type
- horn-volume-delta - Horn volume delta
| [[{{{image}}}|link=|]]
|
Note: This function only works with standard vehicle models. For custom models, it will return the audio settings of the parent model.
|
|
|
Example
-- Retrieve and display the engine-on sound bank ID for Infernus (model 411)
local settings = getVehicleModelAudioSettings(411)
if settings then
outputChatBox("Infernus engine sound ID: " .. tostring(settings["engine-on-soundbank-id"]))
else
outputChatBox("Failed to retrieve audio settings.")
end
See Also