-- rewritten by DaddelZeit local M = {} local chimenode, chime = nil, nil local function initSounds() chime = obj:createSFXSource("vehicles/Toyota_Ae86/sounds/chime.ogg", 'AudioDefaultLoop3D', '', chimenode) obj:setVolume(chime, 2) end local function onInit() for _, n in pairs (v.data.nodes) do if n.name == "speedchime" then chimenode = n.cid end end if chimenode == nil then M.updateGFX = nop M.enable = nop return end -- disable if chime == nil then initSounds() end end local function updateGFX() if chime == nil or electrics.values.wheelspeed == nil then return end -- line below is a check if the camera is in the dampened area around the driver cam obj:queueGameEngineLua('local camObj = getCamera() camObj = (camObj and Sim.upcast(camObj)) or camObj if (core_camera and core_camera.isCameraInside(0, getCameraPosition()) and 1) then be:getPlayerVehicle(0):queueLuaCommand("if speedChime then speedChime.enable(true) end") else be:getPlayerVehicle(0):queueLuaCommand("if speedChime then speedChime.enable(false) end") end') if chimenode ~= nil and electrics.values.wheelspeed > 100 / 3.6 then obj:playSFX(chime) else obj:stopSFX(chime) obj:cutSFX(chime) end end local function enable(bool) if bool == true then obj:setVolumePitch(chime, 4, 1) else obj:setVolumePitch(chime, 0, 1) end end M.initSounds = initSounds M.onInit = onInit M.onReset = onInit M.updateGFX = updateGFX -- feedback from camera damp check M.enable = enable return M