Jump to content

Recommended Posts

I'd like to know what I would have to add to my mod to remove that specific jingle for all players. I'd also like to mute the "going insane" one but that's not as high priority.

Thanks

Edited by certif

Hi. I found what you need (spoiler: not a solution), but I must admit it took me a long time.
When a phase passed, the code activates this function in components/dynamicmusic.lua:

local function OnPhase(inst, phase)
  _isday = phase == "day"
  if _dangertask ~= nil or not _isenabled then
    return
  end
  --Don't want to play overlapping stingers
  local time
  if _busytask == nil and _extendtime ~= 0 then
    time = GetTime()
    if time < _extendtime then
      return
    end
  end
  if _isday then
    _soundemitter:PlaySound("dontstarve/music/music_dawn_stinger") -- <-- You want to disable this
  elseif phase == "dusk" then
    _soundemitter:PlaySound("dontstarve/music/music_dusk_stinger")
  else
    return
  end
  StopBusy()
  --Repurpose this as a delay before stingers or busy can start again
  _extendtime = (time or GetTime()) + 15
end

I said I found what you need, but not a full solution, because, as you can see, the sound path is hardcoded and cannot be modified. To make matters worse, the function that uses PlaySound() can receive an ID as a parameter, which would make it relatively easy to mute the sound, but in this case, it doesn't have one, and I couldn't find a way to get the assigned ID.

It's also worth mentioning that SoundEmitter doesn't seem to be a Lua class, so its contents can't be modified directly. Although it has methods, none of them worked for me.

However, I found a possible path to a solution: the object that plays the sound is TheWorld. You can detect when it runs using inst:WatchWorldState("phase", function(inst, phase) ... end). Additionally, if you run another sound with inst.SoundEmitter:PlaySound(), the previous sound is cut off. Unfortunately, I couldn't find a way to execute that instruction immediately after the sound is played in TheWorld.

To make matters worse, this solution, if possible, would have a significant flaw: game progress is also saved right at the phase when the sound is played. So, if the game freezes (which is very common when saving progress), you would likely hear a snippet of the melody before it gets cut off. You could try using a DoTaskInTime, but if the previous method seemed inelegant, this one seems even worse because you're practically relying on the sound being ready to play at a specific moment you set.

Anyway, I hope this information is at least helpful to someone and maybe it will help you find a solution.

It's also worth adding that everything related to sound seems to be handled not by Lua, but by code in C++ or C, which is nothing new, but makes it practically impossible to modify the sound itself. Of course, you could write Lua code to replace the audio file that's playing, but that could cause antivirus software to detect your mod as a malicious virus, and modifying the original game files doesn't sound like a good idea.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...