Frictional Games Forum (read-only)
[SCRIPT] Custom Music. - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Custom Music. (/thread-29146.html)



Custom Music. - Shylia - 01-07-2015

So I am trying, just a test to see if I can make a custom sound/music work in the game. Now I followed a guide which told me what to do, where to put the files and stuff. But when I'm done scripting I have no idea why it doesn't work.

Could anyone look into it? And give me some tips?

Thanks!

Here is my script.
VVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player", "Ambience", "Ambience1", true, 1);
}

void Ambience1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "CustomTest.snt", "Player", 0.0f, false);
}

I should also mention this one too.

Spoiler below!
<SOUNDENTITY>
<SOUNDS>
<Main>
<Sound File="CustomTest.ogg" />
</Main>
</SOUNDS>
<PROPERTIES Volume="5" MinDistance="1" MaxDistance="50" Random="0" Interval="0" FadeEnd="False" FadeStart="False" Stream="False" Loop="False" Use3D="false" Blockable="False" BlockVolumeMul="0.7" Priority="5" />
</SOUNDENTITY>

ALSO!

If I try to play the OGG file in Windows Mediaplayer I can hear the sound play, but if I try to place the sound in the world in the editor I can't hear it when I try to preview it with the play button, or if I place it in the world and load the map I can't hear the sound play.


RE: Custom Music. - goodcap - 01-07-2015

(01-07-2015, 10:07 AM)Shylia Wrote: So I am trying, just a test to see if I can make a custom sound/music work in the game. Now I followed a guide which told me what to do, where to put the files and stuff. But when I'm done scripting I have no idea why it doesn't work.

Could anyone look into it? And give me some tips?

Thanks!

Here is my script.
VVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player", "Ambience", "Ambience1", true, 1);
}

void Ambience1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "CustomTest.snt", "Player", 0.0f, false);
}

I should also mention this one too.

Spoiler below!
<SOUNDENTITY>
<SOUNDS>
<Main>
<Sound File="CustomTest.ogg" />
</Main>
</SOUNDS>
<PROPERTIES Volume="5" MinDistance="1" MaxDistance="50" Random="0" Interval="0" FadeEnd="False" FadeStart="False" Stream="False" Loop="False" Use3D="false" Blockable="False" BlockVolumeMul="0.7" Priority="5" />
</SOUNDENTITY>

ALSO!

If I try to play the OGG file in Windows Mediaplayer I can hear the sound play, but if I try to place the sound in the world in the editor I can't hear it when I try to preview it with the play button, or if I place it in the world and load the map I can't hear the sound play.

Try changing CustomTest.snt to CustomTest.ogg and see if that works. Like this:

PlaySoundAtEntity("", "CustomTest.ogg", "Player", 0.0f, false);


RE: Custom Music. - Mudbill - 01-07-2015

I would suggest trying PlayGuiSound to see if it works. That one is simpler and more noticeable.

PHP Code:
PlayGuiSound("file.snt"1); 

I believe you can use both SNT and OGG in this script.

Now, make sure you've placed your files correctly. Are they in your custom story directory? If so, I suggest you open the resources.cfg file in the Amnesia root folder and add the "custom_stories" directory to that file if it isn't there already. This will allow the game to search this folder for assets, which might be the reason it's not working.


RE: Custom Music. - Shylia - 01-07-2015

(01-07-2015, 10:52 AM)Mudbill Wrote: I would suggest trying PlayGuiSound to see if it works. That one is simpler and more noticeable.

PHP Code:
PlayGuiSound("file.snt"1); 

I believe you can use both SNT and OGG in this script.

Now, make sure you've placed your files correctly. Are they in your custom story directory? If so, I suggest you open the resources.cfg file in the Amnesia root folder and add the "custom_stories" directory to that file if it isn't there already. This will allow the game to search this folder for assets, which might be the reason it's not working.

How do I go about adding the resources line?


RE: Custom Music. - Romulator - 01-07-2015

Add this line:

Code:
<Directory Path="/custom_stories" AddSubDirs="true" />

to the end of your Resources.cfg file in the directory stated in Mudbill's post above.

Just make sure to put it before the </Resources> line. Smile


RE: Custom Music. - Shylia - 01-07-2015

(01-07-2015, 11:29 AM)Romulator Wrote: Add this line:

Code:
<Directory Path="/custom_stories" AddSubDirs="true" />

to the end of your Resources.cfg file in the directory stated in Mudbill's post above.

Just make sure to put it before the </Resources> line. Smile

Thanks alot, now it works!