Author Topic: Difficulty overwriting sound for BrickBreakSound Datablock  (Read 2023 times)

Hello, I'm having difficulty overwriting a default sound in the game.

code:

Code: [Select]
function SCS_NewSounds()
{
      BreakBrickSound.fileName = "./misc/blank.wav";
}
package Content_Dependencies {
   function BrickBreakSound::onAdd(%this)
   {
         parent::onAdd(%this);
         %this.fileName = "./misc/blank.wav";
   }
};
activatePackage(Content_Dependencies);

BrickBreakSound.getName() returns full path for blank.wav and the eventing gui displays the sound in playSound but when I break a brick with the hammer it's still playing the original sound. When I change the datablock name to a different one such as the default jump sound datablock it works.



I think it's wise that I add why I'm doing this. I want to remove the sound from the game. I then want to parent the killbrick function to play an exact copy of the sound but this time only when a global variable is set for it to do so. I'm doing it because I feel it will improve roleplay when you can choose when the sounds plays (such as when building, etc).

I'm pretty sure you need to point it to the file's actual location, like %this.fileName = "Add-Ons/Server_AludanesAddon/misc/blank.wav";

I'm pretty sure you need to point it to the file's actual location, like %this.fileName = "Add-Ons/Server_AludanesAddon/misc/blank.wav";

using:
Code: [Select]
filePath(expandFileName("./server.cs") @ "/sound/misc/blank.wav");

==>echo(BrickBreakSound.fileName);
Add-Ons/Server_Content_System/sound/misc/blank.wav

Sadly it didn't work when it came to hearing the file but the fileName variable was changed like before :(

You need to parent onAdd AFTER you set file name:
Code: [Select]
function SCS_NewSounds()
{
      BreakBrickSound.fileName = "./misc/blank.wav";
}
package Content_Dependencies {
   function BrickBreakSound::onAdd(%this)
   {
         %this.fileName = "./misc/blank.wav";
         parent::onAdd(%this);
   }
};
activatePackage(Content_Dependencies);

If you parent it before, its just going to add the normal sound, then change the var, which doesnt change the sound.

You need to parent onAdd AFTER you set file name:
Code: [Select]
function SCS_NewSounds()
{
      BreakBrickSound.fileName = "./misc/blank.wav";
}
package Content_Dependencies {
   function BrickBreakSound::onAdd(%this)
   {
         %this.fileName = "./misc/blank.wav";
         parent::onAdd(%this);
   }
};
activatePackage(Content_Dependencies);

If you parent it before, its just going to add the normal sound, then change the var, which doesnt change the sound.

I tried changing the lightOnSound and it worked.
Code: [Select]
function SCS_NewSounds()
{
    lightOnSound.fileName = "./misc/blank.wav";
}
SCS_NewSounds();
package Content_Dependencies {
   function lightOnSound::onAdd(%this)
   {
        %this.fileName = "./misc/blank.wav";
        parent::onAdd(%this);
   }
};
activatePackage(Content_Dependencies);

I replaced "lightOnSound" with "BrickBreakSound", restarted server etc didn't work

Code: [Select]
function SCS_NewSounds()
{
    BrickBreakSound.fileName = "./misc/blank.wav";
}
SCS_NewSounds();
package Content_Dependencies {
   function BrickBreakSound::onAdd(%this)
   {
        %this.fileName = "./misc/blank.wav";
        parent::onAdd(%this);
   }
};
activatePackage(Content_Dependencies);

This is cursed. I feel a dark energy.
« Last Edit: July 13, 2013, 07:14:36 PM by aludane »

Sorry for the bump but I'm still trying to figure out what's going wrong and I couldn't access the forums for a couple of days.

When I replace the sound and make it read-only it's working so I'm certain that the datablock is still using the old filepath to the sound. I know in Ruby you can always inspect an object to see its internal state so is there any way I could dump some information that's inside the datablock?


Sorry for the bump but I'm still trying to figure out what's going wrong and I couldn't access the forums for a couple of days.

When I replace the sound and make it read-only it's working so I'm certain that the datablock is still using the old filepath to the sound. I know in Ruby you can always inspect an object to see its internal state so is there any way I could dump some information that's inside the datablock?



Datablock.dump();

Code: [Select]
==>BrickBreakSound.dump();
Member Fields:
  description = "AudioClose3d"
  fileName = "Add-Ons/Server_SCS/sound/misc/blank.wav"
  preload = "1"
so the fileName variable has changed but hasn't taken effect, could this be a weird case where the datablock is initalized when BL starts up causing any edits to have no effect?

Then don't change the value. Why not completely make a new one?
Code: [Select]
BrickBreakSound.save("config/sound.cs"); save it then change the variable and execute that code inside your add-on somewhere. Then of course delete the previous one