All you need to do is make sure this goes in the path of whatever mod your making and point .truck file to it, I hope they can intigrate it into the game one day ^^ I just thought I'd give this out so the dev's can use it. I did have to duplicate the file and categorize it to not confuse it however the duplicates do interfere with eachother causing the siren to change when you restart the game I also had to rename the siren the original name to make it work and I think the lua script is required because it won't work without it, plus the custom sound file with the original name. All in all, maybe this can be simplified but for now this is what I have figured out. just rename the script from txt to .lua for it to work. I wanted to share this as a contribution to the RoR project btw.
-- Custom Siren Override Script for JapanesePoliceCarPack in Rigs of Rods
local soundFileName = "japanese_siren.wav" -- Custom siren sound file
local soundVolume = 1.0
local triggerKey = "KEY_H" -- Default siren activation key
local soundPlayed = false -- Prevent repeated triggering
-- Function to check if the Japanese Police Car Pack is active
local function isJapanesePolicePackLoaded()
return fileExists(script.scriptPath) -- Check if script runs inside the pack
end
-- Function to play the siren sound
local function playSiren()
if isJapanesePolicePackLoaded() then
local soundPath = string.format("%s/sounds/%s", script.scriptPath, soundFileName) -- Ensure correct path
if fileExists(soundPath) then
playSound(soundPath, soundVolume, false) -- Play sound once
soundPlayed = true
else
log(string.format("[SCRIPT]: WARNING - Sound file not found: %s", soundPath))
end
end
end
-- Event handler for key press
function onKeyPress(event)
if event.key == triggerKey and not soundPlayed then
playSiren()
end
end
-- Event handler for key release
function onKeyRelease(event)
if event.key == triggerKey then
soundPlayed = false -- Reset for next activation
end
end
-- Register key events for Rigs of Rods
addEventHandler("onKeyPress", onKeyPress)
addEventHandler("onKeyRelease", onKeyRelease)
-- Log script loading success
log("[SCRIPT]: Polizei siren overridden when JapanesePoliceCarPack is active.")